# HG changeset patch
# User awilliam@xxxxxxxxxxx
# Node ID 72c5d8206d4882172d9ad1b0c6ad819130e3309f
# Parent fbf676a36ee44558d54db9ebb43a5fe7971d669d
# Parent 13d6d993d79724d86a0c9ac556a7f884baed98ae
merge with xen-unstable.hg
---
linux-2.6-xen-sparse/arch/ia64/xen/xen_ksyms.c | 12
tools/xentrace/tbctl.c | 26
README | 40
buildconfigs/linux-defconfig_xen0_x86_32 | 10
buildconfigs/linux-defconfig_xen0_x86_64 | 10
buildconfigs/linux-defconfig_xenU_x86_32 | 19
buildconfigs/linux-defconfig_xenU_x86_64 | 10
buildconfigs/linux-defconfig_xen_x86_32 | 12
buildconfigs/linux-defconfig_xen_x86_64 | 12
docs/man/xend-config.sxp.pod.5 | 2
docs/man/xm.pod.1 | 18
docs/man/xmdomain.cfg.pod.5 | 4
extras/mini-os/Makefile | 35
extras/mini-os/console/console.c | 10
extras/mini-os/include/mm.h | 90
+
extras/mini-os/include/types.h | 7
extras/mini-os/kernel.c | 22
extras/mini-os/mm.c | 72
-
extras/mini-os/traps.c | 36
extras/mini-os/x86_32.S | 8
extras/mini-os/x86_64.S | 3
linux-2.6-xen-sparse/arch/i386/kernel/fixup.c | 10
linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S | 10
linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c | 10
linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c | 266
++--
linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c | 11
linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c | 10
linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c | 10
linux-2.6-xen-sparse/arch/i386/mm/init-xen.c | 13
linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c | 10
linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c | 10
linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c | 81
-
linux-2.6-xen-sparse/arch/ia64/kernel/setup.c | 3
linux-2.6-xen-sparse/arch/ia64/xen/Makefile | 4
linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c | 7
linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S | 12
linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c | 257
+---
linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S | 16
linux-2.6-xen-sparse/arch/x86_64/kernel/setup-xen.c | 73
-
linux-2.6-xen-sparse/arch/x86_64/mm/init-xen.c | 36
linux-2.6-xen-sparse/drivers/char/tpm/Kconfig | 9
linux-2.6-xen-sparse/drivers/char/tpm/Makefile | 3
linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c | 15
linux-2.6-xen-sparse/drivers/xen/Kconfig | 16
linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c | 14
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c | 21
linux-2.6-xen-sparse/drivers/xen/blkback/common.h | 19
linux-2.6-xen-sparse/drivers/xen/blkback/interface.c | 29
linux-2.6-xen-sparse/drivers/xen/blkback/vbd.c | 23
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c | 15
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c | 12
linux-2.6-xen-sparse/drivers/xen/blkfront/block.h | 10
linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c | 10
linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c | 10
linux-2.6-xen-sparse/drivers/xen/blktap/common.h | 10
linux-2.6-xen-sparse/drivers/xen/blktap/interface.c | 10
linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c | 10
linux-2.6-xen-sparse/drivers/xen/char/mem.c | 10
linux-2.6-xen-sparse/drivers/xen/console/console.c | 14
linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c | 10
linux-2.6-xen-sparse/drivers/xen/core/evtchn.c | 22
linux-2.6-xen-sparse/drivers/xen/core/gnttab.c | 12
linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c | 3
linux-2.6-xen-sparse/drivers/xen/core/reboot.c | 10
linux-2.6-xen-sparse/drivers/xen/core/skbuff.c | 10
linux-2.6-xen-sparse/drivers/xen/core/smpboot.c | 52
linux-2.6-xen-sparse/drivers/xen/core/xen_proc.c | 10
linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c | 7
linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c | 13
linux-2.6-xen-sparse/drivers/xen/net_driver_util.c | 10
linux-2.6-xen-sparse/drivers/xen/netback/common.h | 18
linux-2.6-xen-sparse/drivers/xen/netback/interface.c | 33
linux-2.6-xen-sparse/drivers/xen/netback/loopback.c | 10
linux-2.6-xen-sparse/drivers/xen/netback/netback.c | 23
linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c | 13
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c | 521
+++-----
linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c | 13
linux-2.6-xen-sparse/drivers/xen/tpmback/common.h | 12
linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c | 22
linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c | 14
linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c | 12
linux-2.6-xen-sparse/drivers/xen/util.c | 10
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c | 10
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c | 11
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c | 10
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.h | 10
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c | 10
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c | 19
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c | 10
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h | 10
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h | 2
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h | 3
linux-2.6-xen-sparse/include/asm-i386/mach-xen/setup_arch_post.h | 28
linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h | 6
linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h | 5
linux-2.6-xen-sparse/include/asm-x86_64/e820.h | 63
+
linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h | 16
linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h | 2
linux-2.6-xen-sparse/include/xen/balloon.h | 10
linux-2.6-xen-sparse/include/xen/driver_util.h | 10
linux-2.6-xen-sparse/include/xen/evtchn.h | 10
linux-2.6-xen-sparse/include/xen/foreign_page.h | 10
linux-2.6-xen-sparse/include/xen/gnttab.h | 10
linux-2.6-xen-sparse/include/xen/net_driver_util.h | 10
linux-2.6-xen-sparse/include/xen/public/evtchn.h | 10
linux-2.6-xen-sparse/include/xen/public/privcmd.h | 10
linux-2.6-xen-sparse/include/xen/xen_proc.h | 10
linux-2.6-xen-sparse/include/xen/xenbus.h | 10
patches/linux-2.6.16.13/xen-hotplug.patch | 9
patches/linux-2.6.16.13/xenoprof-generic.patch | 46
tools/examples/README | 13
tools/examples/external-device-migrate | 124
+-
tools/examples/network-bridge | 2
tools/examples/vtpm | 3
tools/examples/vtpm-common.sh | 120
+
tools/examples/xmexample.hvm | 4
tools/examples/xmexample1 | 4
tools/examples/xmexample2 | 4
tools/examples/xmexample3 | 4
tools/firmware/acpi/acpi_dsdt.asl | 10
tools/firmware/acpi/acpi_dsdt.c | 289
++--
tools/firmware/acpi/acpi_fadt.h | 4
tools/ioemu/hw/acpi.c | 178
++
tools/ioemu/hw/cirrus_vga.c | 151
++
tools/ioemu/hw/mc146818rtc.c | 25
tools/ioemu/hw/pc.c | 24
tools/ioemu/hw/pckbd.c | 153
+-
tools/ioemu/hw/serial.c | 1
tools/ioemu/hw/vga.c | 19
tools/ioemu/hw/vga_int.h | 2
tools/ioemu/target-i386-dm/Makefile | 2
tools/ioemu/vl.c | 208
---
tools/ioemu/vl.h | 30
tools/libxc/xc_acm.c | 33
tools/libxc/xc_linux_build.c | 46
tools/libxc/xc_load_elf.c | 69
-
tools/libxc/xc_ptrace.c | 211
+--
tools/libxc/xc_tbuf.c | 31
tools/libxc/xenctrl.h | 42
tools/libxc/xg_private.h | 5
tools/python/xen/lowlevel/acm/acm.c | 54
tools/python/xen/lowlevel/xc/xc.c | 7
tools/python/xen/xend/XendCheckpoint.py | 8
tools/python/xen/xend/XendDomain.py | 6
tools/python/xen/xend/XendDomainInfo.py | 34
tools/python/xen/xend/image.py | 27
tools/python/xen/xend/server/DevController.py | 8
tools/python/xen/xend/server/pciif.py | 25
tools/python/xen/xend/server/tpmif.py | 12
tools/security/Makefile | 4
tools/security/secpol_tool.c | 32
tools/tests/Makefile | 2
tools/vtpm/Makefile | 21
tools/vtpm/tpm_emulator.patch | 1
tools/vtpm/vtpm.patch | 163
--
tools/vtpm_manager/Rules.mk | 8
tools/vtpm_manager/manager/dmictl.c | 142
--
tools/vtpm_manager/manager/securestorage.c | 29
tools/vtpm_manager/manager/vtpm_ipc.c | 141
++
tools/vtpm_manager/manager/vtpm_ipc.h | 71
+
tools/vtpm_manager/manager/vtpm_lock.c | 63
+
tools/vtpm_manager/manager/vtpm_lock.h | 48
tools/vtpm_manager/manager/vtpm_manager.c | 602
----------
tools/vtpm_manager/manager/vtpm_manager.h | 36
tools/vtpm_manager/manager/vtpm_manager_handler.c | 455
+++++++
tools/vtpm_manager/manager/vtpmd.c | 309
++++-
tools/vtpm_manager/manager/vtpmpriv.h | 73
-
tools/xenmon/xenbaked.c | 99
-
tools/xenstore/xenstored_core.c | 17
tools/xenstore/xenstored_domain.c | 9
tools/xenstore/xenstored_domain.h | 2
tools/xenstore/xs_lib.c | 4
tools/xenstore/xs_lib.h | 2
tools/xentrace/Makefile | 2
tools/xentrace/setsize.c | 56
tools/xentrace/xentrace.8 | 75
+
tools/xentrace/xentrace.c | 43
tools/xentrace/xentrace_format | 6
tools/xm-test/configure.ac | 1
tools/xm-test/ramdisk/bin/create_disk_image | 7
tools/xm-test/tests/Makefile.am | 7
tools/xm-test/tests/block-integrity/01_block_device_read_verify.py | 62
+
tools/xm-test/tests/block-integrity/Makefile.am | 21
tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py | 87
+
tools/xm-test/tests/network/03_network_local_tcp_pos.py | 4
tools/xm-test/tests/network/04_network_local_udp_pos.py | 4
tools/xm-test/tests/network/06_network_dom0_tcp_pos.py | 2
tools/xm-test/tests/network/07_network_dom0_udp_pos.py | 2
tools/xm-test/tests/network/12_network_domU_tcp_pos.py | 2
tools/xm-test/tests/network/13_network_domU_udp_pos.py | 2
tools/xm-test/tests/vtpm/04_vtpm-loc_migr.py | 61
-
tools/xm-test/tests/vtpm/05_vtpm-loc_migr.py | 100
+
tools/xm-test/tests/vtpm/Makefile.am | 3
xen/arch/x86/dom0_ops.c | 21
xen/arch/x86/domain.c | 5
xen/arch/x86/hvm/hvm.c | 11
xen/arch/x86/hvm/i8259.c | 88
+
xen/arch/x86/hvm/platform.c | 4
xen/arch/x86/hvm/svm/intr.c | 17
xen/arch/x86/hvm/svm/svm.c | 342
+++--
xen/arch/x86/hvm/svm/vmcb.c | 42
xen/arch/x86/hvm/vmx/vmcs.c | 96
+
xen/arch/x86/hvm/vmx/vmx.c | 5
xen/arch/x86/mm.c | 35
xen/arch/x86/shadow.c | 24
xen/arch/x86/shadow32.c | 8
xen/arch/x86/shadow_public.c | 5
xen/arch/x86/x86_emulate.c | 4
xen/common/acm_ops.c | 282
++--
xen/common/elf.c | 83
-
xen/common/event_channel.c | 3
xen/include/asm-ia64/event.h | 17
xen/include/asm-x86/event.h | 6
xen/include/asm-x86/hvm/svm/svm.h | 8
xen/include/asm-x86/hvm/svm/vmcb.h | 1
xen/include/asm-x86/hvm/vmx/vmcs.h | 2
xen/include/asm-x86/hvm/vpic.h | 3
xen/include/public/acm_ops.h | 54
xen/include/public/arch-ia64.h | 79
-
xen/include/public/arch-x86_32.h | 36
xen/include/public/arch-x86_64.h | 29
xen/include/public/callback.h | 10
xen/include/public/dom0_ops.h | 205
++-
xen/include/public/event_channel.h | 99
-
xen/include/public/grant_table.h | 30
xen/include/public/hvm/ioreq.h | 26
xen/include/public/hvm/vmx_assist.h | 5
xen/include/public/io/blkif.h | 12
xen/include/public/io/netif.h | 32
xen/include/public/io/tpmif.h | 19
xen/include/public/memory.h | 48
xen/include/public/nmi.h | 5
xen/include/public/physdev.h | 45
xen/include/public/sched.h | 15
xen/include/public/vcpu.h | 10
xen/include/public/version.h | 15
xen/include/public/xen.h | 47
xen/include/public/xenoprof.h | 15
xen/include/xen/hypercall.h | 2
xen/include/xen/sched.h | 1
240 files changed, 5232 insertions(+), 4388 deletions(-)
diff -r fbf676a36ee4 -r 72c5d8206d48 README
--- a/README Mon May 22 08:53:26 2006 -0600
+++ b/README Mon May 22 14:13:38 2006 -0600
@@ -1,9 +1,9 @@
################################
- __ __ _____ ___
- \ \/ /___ _ __ |___ / / _ \
+ __ __ _____ ___
+ \ \/ /___ _ __ |___ / / _ \
\ // _ \ '_ \ |_ \| | | |
/ \ __/ | | | ___) | |_| |
- /_/\_\___|_| |_| |____(_)___/
+ /_/\_\___|_| |_| |____(_)___/
################################
@@ -66,14 +66,14 @@ 2. Configure your bootloader to boot Xen
The linux command line takes all the usual options, such as
root=<root-dev> to specify your usual root partition (e.g.,
- /dev/hda1).
+ /dev/hda1).
The Xen command line takes a number of optional arguments described
in the manual. The most common is 'dom0_mem=xxxM' which sets the
amount of memory to allocate for use by your initial virtual
machine (known as domain 0). Note that Xen itself reserves about
32MB memory for internal use, which is not available for allocation
- to virtual machines.
+ to virtual machines.
3. Reboot your system and select the "Xen 3.0 / XenLinux 2.6" menu
option. After booting Xen, Linux will start and your initialisation
@@ -86,7 +86,7 @@ release. Make sure you have all the foll
release. Make sure you have all the following installed, either by
visiting the project webpage or installing a pre-built package
provided by your Linux distributor:
- * GCC (preferably v3.2.x or v3.3.x; older versions are unsupported)
+ * GCC (preferably v3.2.x or v3.3.x; older versions are unsupported)
* GNU Make
* GNU Binutils
* Development install of zlib (e.g., zlib-dev)
@@ -122,19 +122,19 @@ 3. For the very first build, or if you w
# make world
# make install
- This will create and install onto the local machine. It will build
+ This will create and install onto the local machine. It will build
the xen binary (xen.gz), and a linux kernel and modules that can be
used in both dom0 and an unprivileged guest kernel (vmlinuz-2.6.x-xen),
the tools and the documentation.
- You can override the destination for make install by setting DESTDIR
+ You can override the destination for make install by setting DESTDIR
to some value.
- The make command line defaults to building the kernel vmlinuz-2.6.x-xen.
- You can override this default by specifying KERNELS=kernelname. For
- example, you can make two kernels - linux-2.6-xen0
- and linux-2.6-xenU - which are smaller builds containing only selected
- modules, intended primarily for developers that don't like to wait
+ The make command line defaults to building the kernel vmlinuz-2.6.x-xen.
+ You can override this default by specifying KERNELS=kernelname. For
+ example, you can make two kernels - linux-2.6-xen0
+ and linux-2.6-xenU - which are smaller builds containing only selected
+ modules, intended primarily for developers that don't like to wait
for a full -xen kernel to build. The -xenU kernel is particularly small,
as it does not contain any physical device drivers, and hence is
only useful for guest domains.
@@ -153,15 +153,15 @@ 4. To rebuild an existing tree without m
# make dist
This will build and install xen, kernels, tools, and
- docs into the local dist/ directory.
+ docs into the local dist/ directory.
- You can override the destination for make install by setting DISTDIR
+ You can override the destination for make install by setting DISTDIR
to some value.
- make install and make dist differ in that make install does the
- right things for your local machine (installing the appropriate
- version of hotplug or udev scripts, for example), but make dist
- includes all versions of those scripts, so that you can copy the dist
+ make install and make dist differ in that make install does the
+ right things for your local machine (installing the appropriate
+ version of hotplug or udev scripts, for example), but make dist
+ includes all versions of those scripts, so that you can copy the dist
directory to another machine and install from that distribution.
5. To rebuild a kernel with a modified config:
@@ -171,6 +171,6 @@ 5. To rebuild a kernel with a modified c
# make linux-2.6-xen-install
Depending on your config, you may need to use 'mkinitrd' to create
- an initial ram disk, just like a native system e.g.
+ an initial ram disk, just like a native system e.g.
# depmod 2.6.16-xen
# mkinitrd -v -f --with=aacraid --with=sd_mod --with=scsi_mod
initrd-2.6.16-xen.img 2.6.16-xen
diff -r fbf676a36ee4 -r 72c5d8206d48 buildconfigs/linux-defconfig_xen0_x86_32
--- a/buildconfigs/linux-defconfig_xen0_x86_32 Mon May 22 08:53:26 2006 -0600
+++ b/buildconfigs/linux-defconfig_xen0_x86_32 Mon May 22 14:13:38 2006 -0600
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.16-xen0
-# Sat Apr 8 11:34:07 2006
+# Linux kernel version: 2.6.16.13-xen0
+# Thu May 11 17:06:31 2006
#
CONFIG_X86_32=y
CONFIG_SEMAPHORE_SLEEPERS=y
@@ -1309,7 +1309,7 @@ CONFIG_CRYPTO_CRC32C=m
#
# CONFIG_CRYPTO_DEV_PADLOCK is not set
CONFIG_XEN=y
-CONFIG_XEN_INTERFACE_VERSION=0x00030101
+CONFIG_XEN_INTERFACE_VERSION=0x00030202
#
# XEN
@@ -1330,10 +1330,12 @@ CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_NETDEV_FRONTEND=y
# CONFIG_XEN_BLKDEV_TAP is not set
-# CONFIG_XEN_TPMDEV_FRONTEND is not set
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DISABLE_SERIAL=y
CONFIG_XEN_SYSFS=y
+CONFIG_XEN_COMPAT_030002_AND_LATER=y
+# CONFIG_XEN_COMPAT_LATEST_ONLY is not set
+CONFIG_XEN_COMPAT_030002=y
CONFIG_HAVE_ARCH_ALLOC_SKB=y
CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
CONFIG_NO_IDLE_HZ=y
diff -r fbf676a36ee4 -r 72c5d8206d48 buildconfigs/linux-defconfig_xen0_x86_64
--- a/buildconfigs/linux-defconfig_xen0_x86_64 Mon May 22 08:53:26 2006 -0600
+++ b/buildconfigs/linux-defconfig_xen0_x86_64 Mon May 22 14:13:38 2006 -0600
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.16-xen0
-# Thu Apr 13 14:58:29 2006
+# Linux kernel version: 2.6.16.13-xen0
+# Thu May 11 17:17:19 2006
#
CONFIG_X86_64=y
CONFIG_64BIT=y
@@ -1250,7 +1250,7 @@ CONFIG_CRYPTO_CRC32C=m
# Hardware crypto devices
#
CONFIG_XEN=y
-CONFIG_XEN_INTERFACE_VERSION=0x00030101
+CONFIG_XEN_INTERFACE_VERSION=0x00030202
#
# XEN
@@ -1271,10 +1271,12 @@ CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_NETDEV_FRONTEND=y
# CONFIG_XEN_BLKDEV_TAP is not set
-# CONFIG_XEN_TPMDEV_FRONTEND is not set
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DISABLE_SERIAL=y
CONFIG_XEN_SYSFS=y
+CONFIG_XEN_COMPAT_030002_AND_LATER=y
+# CONFIG_XEN_COMPAT_LATEST_ONLY is not set
+CONFIG_XEN_COMPAT_030002=y
CONFIG_HAVE_ARCH_ALLOC_SKB=y
CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
CONFIG_NO_IDLE_HZ=y
diff -r fbf676a36ee4 -r 72c5d8206d48 buildconfigs/linux-defconfig_xenU_x86_32
--- a/buildconfigs/linux-defconfig_xenU_x86_32 Mon May 22 08:53:26 2006 -0600
+++ b/buildconfigs/linux-defconfig_xenU_x86_32 Mon May 22 14:13:38 2006 -0600
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.16-rc3-xen0
-# Thu Feb 16 22:53:43 2006
+# Linux kernel version: 2.6.16.13-xenU
+# Thu May 11 17:08:12 2006
#
CONFIG_X86_32=y
CONFIG_SEMAPHORE_SLEEPERS=y
@@ -617,11 +617,7 @@ CONFIG_DUMMY_CONSOLE=y
#
#
-# SN Devices
-#
-
-#
-# EDAC - error detection and reporting (RAS)
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
#
# CONFIG_EDAC is not set
@@ -852,7 +848,7 @@ CONFIG_CRYPTO_CRC32C=m
#
# CONFIG_CRYPTO_DEV_PADLOCK is not set
CONFIG_XEN=y
-CONFIG_NO_IDLE_HZ=y
+CONFIG_XEN_INTERFACE_VERSION=0x00030202
#
# XEN
@@ -862,12 +858,15 @@ CONFIG_XEN_UNPRIVILEGED_GUEST=y
# CONFIG_XEN_BACKEND is not set
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_NETDEV_FRONTEND=y
-# CONFIG_XEN_TPMDEV_FRONTEND is not set
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DISABLE_SERIAL=y
CONFIG_XEN_SYSFS=y
+CONFIG_XEN_COMPAT_030002_AND_LATER=y
+# CONFIG_XEN_COMPAT_LATEST_ONLY is not set
+CONFIG_XEN_COMPAT_030002=y
CONFIG_HAVE_ARCH_ALLOC_SKB=y
CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
+CONFIG_NO_IDLE_HZ=y
#
# Library routines
@@ -883,4 +882,6 @@ CONFIG_X86_SMP=y
CONFIG_X86_SMP=y
CONFIG_X86_BIOS_REBOOT=y
CONFIG_X86_TRAMPOLINE=y
+CONFIG_X86_NO_TSS=y
+CONFIG_X86_NO_IDT=y
CONFIG_KTIME_SCALAR=y
diff -r fbf676a36ee4 -r 72c5d8206d48 buildconfigs/linux-defconfig_xenU_x86_64
--- a/buildconfigs/linux-defconfig_xenU_x86_64 Mon May 22 08:53:26 2006 -0600
+++ b/buildconfigs/linux-defconfig_xenU_x86_64 Mon May 22 14:13:38 2006 -0600
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.16-xenU
-# Thu Apr 13 14:59:16 2006
+# Linux kernel version: 2.6.16.13-xenU
+# Thu May 11 17:17:57 2006
#
CONFIG_X86_64=y
CONFIG_64BIT=y
@@ -1135,7 +1135,7 @@ CONFIG_CRYPTO_CRC32C=m
# Hardware crypto devices
#
CONFIG_XEN=y
-CONFIG_XEN_INTERFACE_VERSION=0x00030101
+CONFIG_XEN_INTERFACE_VERSION=0x00030202
#
# XEN
@@ -1145,10 +1145,12 @@ CONFIG_XEN_UNPRIVILEGED_GUEST=y
# CONFIG_XEN_BACKEND is not set
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_NETDEV_FRONTEND=y
-# CONFIG_XEN_TPMDEV_FRONTEND is not set
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DISABLE_SERIAL=y
CONFIG_XEN_SYSFS=y
+CONFIG_XEN_COMPAT_030002_AND_LATER=y
+# CONFIG_XEN_COMPAT_LATEST_ONLY is not set
+CONFIG_XEN_COMPAT_030002=y
CONFIG_HAVE_ARCH_ALLOC_SKB=y
CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
CONFIG_NO_IDLE_HZ=y
diff -r fbf676a36ee4 -r 72c5d8206d48 buildconfigs/linux-defconfig_xen_x86_32
--- a/buildconfigs/linux-defconfig_xen_x86_32 Mon May 22 08:53:26 2006 -0600
+++ b/buildconfigs/linux-defconfig_xen_x86_32 Mon May 22 14:13:38 2006 -0600
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.16-xen
-# Thu Apr 20 17:07:18 2006
+# Linux kernel version: 2.6.16.13-xen
+# Thu May 11 17:11:00 2006
#
CONFIG_X86_32=y
CONFIG_SEMAPHORE_SLEEPERS=y
@@ -888,7 +888,7 @@ CONFIG_MTD_NAND_DISKONCHIP=m
# CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADVANCED is not set
CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDRESS=0
CONFIG_MTD_NAND_DISKONCHIP_BBTWRITE=y
-CONFIG_MTD_NAND_NANDSIM=y
+CONFIG_MTD_NAND_NANDSIM=m
#
# OneNAND Flash Device Drivers
@@ -3009,7 +3009,7 @@ CONFIG_CRYPTO_TEST=m
#
# CONFIG_CRYPTO_DEV_PADLOCK is not set
CONFIG_XEN=y
-CONFIG_XEN_INTERFACE_VERSION=0x00030101
+CONFIG_XEN_INTERFACE_VERSION=0x00030202
#
# XEN
@@ -3030,10 +3030,12 @@ CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_NETDEV_FRONTEND=y
# CONFIG_XEN_BLKDEV_TAP is not set
-CONFIG_XEN_TPMDEV_FRONTEND=m
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DISABLE_SERIAL=y
CONFIG_XEN_SYSFS=y
+CONFIG_XEN_COMPAT_030002_AND_LATER=y
+# CONFIG_XEN_COMPAT_LATEST_ONLY is not set
+CONFIG_XEN_COMPAT_030002=y
CONFIG_HAVE_ARCH_ALLOC_SKB=y
CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
CONFIG_NO_IDLE_HZ=y
diff -r fbf676a36ee4 -r 72c5d8206d48 buildconfigs/linux-defconfig_xen_x86_64
--- a/buildconfigs/linux-defconfig_xen_x86_64 Mon May 22 08:53:26 2006 -0600
+++ b/buildconfigs/linux-defconfig_xen_x86_64 Mon May 22 14:13:38 2006 -0600
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.16-xen
-# Thu Apr 20 17:05:48 2006
+# Linux kernel version: 2.6.16.13-xen
+# Thu May 11 17:18:58 2006
#
CONFIG_X86_64=y
CONFIG_64BIT=y
@@ -840,7 +840,7 @@ CONFIG_MTD_NAND_DISKONCHIP=m
# CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADVANCED is not set
CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDRESS=0
CONFIG_MTD_NAND_DISKONCHIP_BBTWRITE=y
-CONFIG_MTD_NAND_NANDSIM=y
+CONFIG_MTD_NAND_NANDSIM=m
#
# OneNAND Flash Device Drivers
@@ -2841,7 +2841,7 @@ CONFIG_CRYPTO_TEST=m
# Hardware crypto devices
#
CONFIG_XEN=y
-CONFIG_XEN_INTERFACE_VERSION=0x00030101
+CONFIG_XEN_INTERFACE_VERSION=0x00030202
#
# XEN
@@ -2863,10 +2863,12 @@ CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_NETDEV_FRONTEND=y
# CONFIG_XEN_BLKDEV_TAP is not set
-CONFIG_XEN_TPMDEV_FRONTEND=m
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DISABLE_SERIAL=y
CONFIG_XEN_SYSFS=y
+CONFIG_XEN_COMPAT_030002_AND_LATER=y
+# CONFIG_XEN_COMPAT_LATEST_ONLY is not set
+CONFIG_XEN_COMPAT_030002=y
CONFIG_HAVE_ARCH_ALLOC_SKB=y
CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
CONFIG_NO_IDLE_HZ=y
diff -r fbf676a36ee4 -r 72c5d8206d48 docs/man/xend-config.sxp.pod.5
--- a/docs/man/xend-config.sxp.pod.5 Mon May 22 08:53:26 2006 -0600
+++ b/docs/man/xend-config.sxp.pod.5 Mon May 22 14:13:38 2006 -0600
@@ -107,7 +107,7 @@ If the value is 0, all available CPUs wi
=item I<enable-dump>
A boolean value that tells xend whether or not core dumps of guest
-domains should be saved when a crash occurrs. Defaults to I<no>.
+domains should be saved when a crash occurs. Defaults to I<no>.
=item I<external-migration-tool>
diff -r fbf676a36ee4 -r 72c5d8206d48 docs/man/xm.pod.1
--- a/docs/man/xm.pod.1 Mon May 22 08:53:26 2006 -0600
+++ b/docs/man/xm.pod.1 Mon May 22 14:13:38 2006 -0600
@@ -27,12 +27,12 @@ each of those sub commands.
=head1 NOTES
-All B<xm> opperations rely upon the Xen control daemon, aka B<xend>.
+All B<xm> operations rely upon the Xen control daemon, aka B<xend>.
For any xm commands to run xend must also be running. For this reason
you should start xend as a service when your system first boots using
xen.
-Most B<xm> commands require root privledges to run due to the
+Most B<xm> commands require root privileges to run due to the
communications channels used to talk to the hypervisor. Running as
non root will return an error.
@@ -169,7 +169,7 @@ The domain is currently running on a CPU
=item B<b - blocked>
-The domain is blocked, and not running or runable. This can be caused
+The domain is blocked, and not running or runnable. This can be caused
because the domain is waiting on IO (a traditional wait state) or has
gone to sleep because there was nothing else for it to do.
@@ -260,7 +260,7 @@ careful when using this command on runni
Migrate a domain to another Host machine. B<Xend> must be running on
other host machine, it must be running the same version of xen, it
-must have the migration tcp port open and accepting connections from
+must have the migration TCP port open and accepting connections from
the source host, and there must be sufficient resources for the domain
to run (memory, disk, etc).
@@ -337,7 +337,7 @@ severed upon restore, as TCP timeouts ma
=item B<shutdown> I<[options]> I<domain-id>
Gracefully shuts down a domain. This coordinates with the domain OS
-to perform graceful shutdown, so there is no guaruntee that it will
+to perform graceful shutdown, so there is no guarantee that it will
succeed, and may take a variable length of time depending on what
services must be shutdown in the domain. The command returns
immediately after signally the domain unless that I<-w> flag is used.
@@ -573,11 +573,11 @@ B<PARAMETERS>
=item I<period>
-The normal EDF scheduling usage in nanosecs
+The normal EDF scheduling usage in nanoseconds
=item I<slice>
-The normal EDF scheduling usage in nanosecs
+The normal EDF scheduling usage in nanoseconds
FIXME: these are lame, should explain more.
@@ -726,7 +726,7 @@ circumstances this should actually work.
=item I<mac=macaddr>
-The MAC address that the domain will see on its ethernet device. If
+The MAC address that the domain will see on its Ethernet device. If
the device is not specified it will be randomly generated with the
00:16:3e vendor id prefix.
@@ -768,7 +768,7 @@ formatted as a list or as an S-Expressio
The Virtual Network interfaces for Xen.
-FIXME: This needs a lot more explaination, or it needs to be ripped
+FIXME: This needs a lot more explanation, or it needs to be ripped
out entirely.
=over 4
diff -r fbf676a36ee4 -r 72c5d8206d48 docs/man/xmdomain.cfg.pod.5
--- a/docs/man/xmdomain.cfg.pod.5 Mon May 22 08:53:26 2006 -0600
+++ b/docs/man/xmdomain.cfg.pod.5 Mon May 22 14:13:38 2006 -0600
@@ -80,7 +80,7 @@ An array of block device stanzas, in the
disk = [ "stanza1", "stanza2", ... ]
-Each stanza has 3 terms, seperated by commas,
+Each stanza has 3 terms, separated by commas,
"backend-dev,frontend-dev,mode".
=over 4
@@ -112,7 +112,7 @@ I<r> (read-only), I<w> (read/write).
=item B<vif>
-An arrray of virtual interface stanzas in the form:
+An array of virtual interface stanzas in the form:
vif = [ "stanza1", "stanza2", ... ]
diff -r fbf676a36ee4 -r 72c5d8206d48 extras/mini-os/Makefile
--- a/extras/mini-os/Makefile Mon May 22 08:53:26 2006 -0600
+++ b/extras/mini-os/Makefile Mon May 22 14:13:38 2006 -0600
@@ -1,4 +1,5 @@ debug ?= y
debug ?= y
+pae ?= n
include $(CURDIR)/../../Config.mk
@@ -6,18 +7,28 @@ override TARGET_ARCH := $(XEN_TARGET
override TARGET_ARCH := $(XEN_TARGET_ARCH)
# NB. '-Wcast-qual' is nasty, so I omitted it.
-CFLAGS := -fno-builtin -Wall -Werror -Iinclude/ -Wredundant-decls -Wno-format
+CFLAGS := -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format
CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline
+
+override CPPFLAGS := -Iinclude $(CPPFLAGS)
+ASFLAGS = -D__ASSEMBLY__
+
+LDFLAGS := -N -T minios-$(TARGET_ARCH).lds
ifeq ($(TARGET_ARCH),x86_32)
CFLAGS += -m32 -march=i686
-LDFLAGS := -m elf_i386
+LDFLAGS += -m elf_i386
+endif
+
+ifeq ($(TARGET_ARCH)$(pae),x86_32y)
+CFLAGS += -DCONFIG_X86_PAE=1
+ASFLAGS += -DCONFIG_X86_PAE=1
endif
ifeq ($(TARGET_ARCH),x86_64)
CFLAGS += -m64 -mno-red-zone -fpic -fno-reorder-blocks
CFLAGS += -fno-asynchronous-unwind-tables
-LDFLAGS := -m elf_x86_64
+LDFLAGS += -m elf_x86_64
endif
ifeq ($(debug),y)
@@ -28,12 +39,12 @@ endif
TARGET := mini-os
-OBJS := $(TARGET_ARCH).o
-OBJS += $(patsubst %.c,%.o,$(wildcard *.c))
+HEAD := $(TARGET_ARCH).o
+OBJS := $(patsubst %.c,%.o,$(wildcard *.c))
OBJS += $(patsubst %.c,%.o,$(wildcard lib/*.c))
OBJS += $(patsubst %.c,%.o,$(wildcard xenbus/*.c))
OBJS += $(patsubst %.c,%.o,$(wildcard console/*.c))
-
+
HDRS := $(wildcard include/*.h)
HDRS += $(wildcard include/xen/*.h)
@@ -44,21 +55,25 @@ links:
links:
[ -e include/xen ] || ln -sf ../../../xen/include/public include/xen
-$(TARGET): links $(OBJS)
- $(LD) -N -T minios-$(TARGET_ARCH).lds $(OBJS) -o $@.elf
+libminios.a: $(OBJS) $(HEAD)
+ ar r libminios.a $(HEAD) $(OBJS)
+
+$(TARGET): links libminios.a $(HEAD)
+ $(LD) $(LDFLAGS) $(HEAD) -L. -lminios -o $@.elf
gzip -f -9 -c $@.elf >$@.gz
.PHONY: clean
clean:
find . -type f -name '*.o' | xargs rm -f
rm -f *.o *~ core $(TARGET).elf $(TARGET).raw $(TARGET) $(TARGET).gz
+ rm -f libminios.a
find . -type l | xargs rm -f
%.o: %.c $(HDRS) Makefile
- $(CC) $(CFLAGS) -c $< -o $@
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
%.o: %.S $(HDRS) Makefile
- $(CC) $(CFLAGS) -D__ASSEMBLY__ -c $< -o $@
+ $(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@
define all_sources
( find . -follow -name SCCS -prune -o -name '*.[chS]' -print )
diff -r fbf676a36ee4 -r 72c5d8206d48 extras/mini-os/console/console.c
--- a/extras/mini-os/console/console.c Mon May 22 08:53:26 2006 -0600
+++ b/extras/mini-os/console/console.c Mon May 22 14:13:38 2006 -0600
@@ -45,6 +45,10 @@
#include <xen/io/console.h>
+/* Copies all print output to the Xen emergency console apart
+ of standard dom0 handled console */
+#define USE_XEN_CONSOLE
+
/* Low level functions defined in xencons_ring.c */
extern int xencons_ring_init(void);
extern int xencons_ring_send(const char *data, unsigned len);
@@ -117,7 +121,9 @@ void print(int direct, const char *fmt,
(void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(buf), buf);
return;
} else {
- if(!console_initialised)
+#ifndef USE_XEN_CONSOLE
+ if(!console_initialised)
+#endif
(void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(buf), buf);
console_print(buf, strlen(buf));
@@ -128,7 +134,7 @@ void printk(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
- print(1, fmt, args);
+ print(0, fmt, args);
va_end(args);
}
diff -r fbf676a36ee4 -r 72c5d8206d48 extras/mini-os/include/mm.h
--- a/extras/mini-os/include/mm.h Mon May 22 08:53:26 2006 -0600
+++ b/extras/mini-os/include/mm.h Mon May 22 14:13:38 2006 -0600
@@ -43,6 +43,8 @@
#if defined(__i386__)
+#if !defined(CONFIG_X86_PAE)
+
#define L2_PAGETABLE_SHIFT 22
#define L1_PAGETABLE_ENTRIES 1024
@@ -50,6 +52,30 @@
#define PADDR_BITS 32
#define PADDR_MASK (~0UL)
+
+#define UNMAPPED_PT_FRAMES 1
+#define PRIpte "08lx"
+typedef unsigned long pgentry_t;
+
+#else /* defined(CONFIG_X86_PAE) */
+
+#define L2_PAGETABLE_SHIFT 21
+#define L3_PAGETABLE_SHIFT 30
+
+#define L1_PAGETABLE_ENTRIES 512
+#define L2_PAGETABLE_ENTRIES 512
+#define L3_PAGETABLE_ENTRIES 4
+
+#define PADDR_BITS 44
+#define PADDR_MASK ((1ULL << PADDR_BITS)-1)
+
+#define L2_MASK ((1UL << L3_PAGETABLE_SHIFT) - 1)
+
+#define UNMAPPED_PT_FRAMES 2
+#define PRIpte "016llx"
+typedef uint64_t pgentry_t;
+
+#endif /* !defined(CONFIG_X86_PAE) */
#elif defined(__x86_64__)
@@ -81,6 +107,10 @@
#define L2_MASK ((1UL << L3_PAGETABLE_SHIFT) - 1)
#define L3_MASK ((1UL << L4_PAGETABLE_SHIFT) - 1)
+#define UNMAPPED_PT_FRAMES 3
+#define PRIpte "016lx"
+typedef unsigned long pgentry_t;
+
#endif
#define L1_MASK ((1UL << L2_PAGETABLE_SHIFT) - 1)
@@ -90,9 +120,11 @@
(((_a) >> L1_PAGETABLE_SHIFT) & (L1_PAGETABLE_ENTRIES - 1))
#define l2_table_offset(_a) \
(((_a) >> L2_PAGETABLE_SHIFT) & (L2_PAGETABLE_ENTRIES - 1))
-#if defined(__x86_64__)
+#if defined(__x86_64__) || defined(CONFIG_X86_PAE)
#define l3_table_offset(_a) \
(((_a) >> L3_PAGETABLE_SHIFT) & (L3_PAGETABLE_ENTRIES - 1))
+#endif
+#if defined(__x86_64__)
#define l4_table_offset(_a) \
(((_a) >> L4_PAGETABLE_SHIFT) & (L4_PAGETABLE_ENTRIES - 1))
#endif
@@ -111,14 +143,21 @@
#if defined(__i386__)
#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
#define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY |_PAGE_USER)
+#if defined(CONFIG_X86_PAE)
+#define L3_PROT (_PAGE_PRESENT)
+#endif /* CONFIG_X86_PAE */
#elif defined(__x86_64__)
#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_USER)
#define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
#define L3_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
#define L4_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
-#endif
-
+#endif /* __i386__ || __x86_64__ */
+
+#ifndef CONFIG_X86_PAE
#define PAGE_SIZE (1UL << L1_PAGETABLE_SHIFT)
+#else
+#define PAGE_SIZE (1ULL << L1_PAGETABLE_SHIFT)
+#endif
#define PAGE_SHIFT L1_PAGETABLE_SHIFT
#define PAGE_MASK (~(PAGE_SIZE-1))
@@ -129,36 +168,41 @@
/* to align the pointer to the (next) page boundary */
#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
+/* Definitions for machine and pseudophysical addresses. */
+#ifdef CONFIG_X86_PAE
+typedef unsigned long long paddr_t;
+typedef unsigned long long maddr_t;
+#else
+typedef unsigned long paddr_t;
+typedef unsigned long maddr_t;
+#endif
+
extern unsigned long *phys_to_machine_mapping;
+extern char _text, _etext, _edata, _end;
#define pfn_to_mfn(_pfn) (phys_to_machine_mapping[(_pfn)])
-static __inline__ unsigned long phys_to_machine(unsigned long phys)
-{
- unsigned long machine = pfn_to_mfn(phys >> L1_PAGETABLE_SHIFT);
- machine = (machine << L1_PAGETABLE_SHIFT) | (phys & ~PAGE_MASK);
- return machine;
-}
-
+static __inline__ maddr_t phys_to_machine(paddr_t phys)
+{
+ maddr_t machine = pfn_to_mfn(phys >> PAGE_SHIFT);
+ machine = (machine << PAGE_SHIFT) | (phys & ~PAGE_MASK);
+ return machine;
+}
#define mfn_to_pfn(_mfn) (machine_to_phys_mapping[(_mfn)])
-static __inline__ unsigned long machine_to_phys(unsigned long machine)
-{
- unsigned long phys = mfn_to_pfn(machine >> L1_PAGETABLE_SHIFT);
- phys = (phys << L1_PAGETABLE_SHIFT) | (machine & ~PAGE_MASK);
- return phys;
-}
-
-#if defined(__x86_64__)
-#define VIRT_START 0xFFFFFFFF80000000UL
-#elif defined(__i386__)
-#define VIRT_START 0xC0000000UL
-#endif
+static __inline__ paddr_t machine_to_phys(maddr_t machine)
+{
+ paddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT);
+ phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK);
+ return phys;
+}
+
+#define VIRT_START ((unsigned long)&_text)
#define to_phys(x) ((unsigned long)(x)-VIRT_START)
#define to_virt(x) ((void *)((unsigned long)(x)+VIRT_START))
#define virt_to_pfn(_virt) (PFN_DOWN(to_phys(_virt)))
#define mach_to_virt(_mach) (to_virt(machine_to_phys(_mach)))
-#define mfn_to_virt(_mfn) (mach_to_virt(_mfn << PAGE_SHIFT))
+#define mfn_to_virt(_mfn) (to_virt(mfn_to_pfn(_mfn) << PAGE_SHIFT))
#define pfn_to_virt(_pfn) (to_virt(_pfn << PAGE_SHIFT))
/* Pagetable walking. */
diff -r fbf676a36ee4 -r 72c5d8206d48 extras/mini-os/include/types.h
--- a/extras/mini-os/include/types.h Mon May 22 08:53:26 2006 -0600
+++ b/extras/mini-os/include/types.h Mon May 22 14:13:38 2006 -0600
@@ -43,14 +43,19 @@ typedef unsigned long long u_quad_t;
typedef unsigned long long u_quad_t;
typedef unsigned int uintptr_t;
+#if !defined(CONFIG_X86_PAE)
typedef struct { unsigned long pte_low; } pte_t;
+#else
+typedef struct { unsigned long pte_low, pte_high; } pte_t;
+#endif /* CONFIG_X86_PAE */
+
#elif defined(__x86_64__)
typedef long quad_t;
typedef unsigned long u_quad_t;
typedef unsigned long uintptr_t;
typedef struct { unsigned long pte; } pte_t;
-#endif
+#endif /* __i386__ || __x86_64__ */
typedef u8 uint8_t;
typedef s8 int8_t;
diff -r fbf676a36ee4 -r 72c5d8206d48 extras/mini-os/kernel.c
--- a/extras/mini-os/kernel.c Mon May 22 08:53:26 2006 -0600
+++ b/extras/mini-os/kernel.c Mon May 22 14:13:38 2006 -0600
@@ -63,7 +63,12 @@ void failsafe_callback(void);
extern char shared_info[PAGE_SIZE];
+#if !defined(CONFIG_X86_PAE)
#define __pte(x) ((pte_t) { (x) } )
+#else
+#define __pte(x) ({ unsigned long long _x = (x); \
+ ((pte_t) {(unsigned long)(_x), (unsigned long)(_x>>32)}); })
+#endif
static shared_info_t *map_shared_info(unsigned long pa)
{
@@ -71,7 +76,7 @@ static shared_info_t *map_shared_info(un
(unsigned long)shared_info, __pte(pa | 7), UVMF_INVLPG) )
{
printk("Failed to map shared_info!!\n");
- *(int*)0=0;
+ do_exit();
}
return (shared_info_t *)shared_info;
}
@@ -106,6 +111,12 @@ void setup_xen_features(void)
}
}
+/* This should be overridden by the application we are linked against. */
+__attribute__((weak)) int app_main(start_info_t *si)
+{
+ printk("Dummy main: start_info=%p\n", si);
+ return 0;
+}
/*
* INITIAL C ENTRY POINT.
@@ -120,6 +131,10 @@ void start_kernel(start_info_t *si)
/* WARN: don't do printk before here, it uses information from
shared_info. Use xprintk instead. */
memcpy(&start_info, si, sizeof(*si));
+
+ /* set up minimal memory infos */
+ phys_to_machine_mapping = (unsigned long *)start_info.mfn_list;
+
/* Grab the shared_info pointer and put it in a safe place. */
HYPERVISOR_shared_info = map_shared_info(start_info.shared_info);
@@ -165,12 +180,15 @@ void start_kernel(start_info_t *si)
/* Init the console driver. */
init_console();
- /* Init scheduler. */
+ /* Init scheduler. */
init_sched();
/* Init XenBus from a separate thread */
create_thread("init_xs", init_xs, NULL);
+ /* Call (possibly overridden) app_main() */
+ app_main(&start_info);
+
/* Everything initialised, start idle thread */
run_idle_thread();
}
diff -r fbf676a36ee4 -r 72c5d8206d48 extras/mini-os/mm.c
--- a/extras/mini-os/mm.c Mon May 22 08:53:26 2006 -0600
+++ b/extras/mini-os/mm.c Mon May 22 14:13:38 2006 -0600
@@ -50,7 +50,6 @@
unsigned long *phys_to_machine_mapping;
extern char *stack;
-extern char _text, _etext, _edata, _end;
extern void page_walk(unsigned long virt_addr);
/*********************
@@ -369,7 +368,7 @@ void new_pt_frame(unsigned long *pt_pfn,
void new_pt_frame(unsigned long *pt_pfn, unsigned long prev_l_mfn,
unsigned long offset, unsigned long level)
{
- unsigned long *tab = (unsigned long *)start_info.pt_base;
+ pgentry_t *tab = (pgentry_t *)start_info.pt_base;
unsigned long pt_page = (unsigned long)pfn_to_virt(*pt_pfn);
unsigned long prot_e, prot_t, pincmd;
mmu_update_t mmu_updates[1];
@@ -383,40 +382,45 @@ void new_pt_frame(unsigned long *pt_pfn,
as a page table page */
memset((unsigned long*)pfn_to_virt(*pt_pfn), 0, PAGE_SIZE);
- if (level == L1_FRAME)
- {
+ switch ( level )
+ {
+ case L1_FRAME:
prot_e = L1_PROT;
prot_t = L2_PROT;
pincmd = MMUEXT_PIN_L1_TABLE;
- }
-#if (defined __x86_64__)
- else if (level == L2_FRAME)
- {
+ break;
+#if defined(__x86_64__) || defined(CONFIG_X86_PAE)
+ case L2_FRAME:
prot_e = L2_PROT;
prot_t = L3_PROT;
pincmd = MMUEXT_PIN_L2_TABLE;
- }
- else if (level == L3_FRAME)
- {
+ break;
+#endif
+#if defined(__x86_64__)
+ case L3_FRAME:
prot_e = L3_PROT;
prot_t = L4_PROT;
pincmd = MMUEXT_PIN_L3_TABLE;
- }
-#endif
- else
- {
+ break;
+#endif
+ default:
printk("new_pt_frame() called with invalid level number %d\n", level);
do_exit();
- }
+ break;
+ }
/* Update the entry */
-#if (defined __x86_64__)
+#if defined(__x86_64__)
tab = pte_to_virt(tab[l4_table_offset(pt_page)]);
tab = pte_to_virt(tab[l3_table_offset(pt_page)]);
#endif
- mmu_updates[0].ptr = (tab[l2_table_offset(pt_page)] & PAGE_MASK) +
- sizeof(void *)* l1_table_offset(pt_page);
- mmu_updates[0].val = pfn_to_mfn(*pt_pfn) << PAGE_SHIFT |
+#if defined(CONFIG_X86_PAE)
+ tab = pte_to_virt(tab[l3_table_offset(pt_page)]);
+#endif
+
+ mmu_updates[0].ptr = ((pgentry_t)tab[l2_table_offset(pt_page)] &
PAGE_MASK) +
+ sizeof(pgentry_t) * l1_table_offset(pt_page);
+ mmu_updates[0].val = (pgentry_t)pfn_to_mfn(*pt_pfn) << PAGE_SHIFT |
(prot_e & ~_PAGE_RW);
if(HYPERVISOR_mmu_update(mmu_updates, 1, NULL, DOMID_SELF) < 0)
{
@@ -435,8 +439,8 @@ void new_pt_frame(unsigned long *pt_pfn,
/* Now fill the new page table page with entries.
Update the page directory as well. */
- mmu_updates[0].ptr = (prev_l_mfn << PAGE_SHIFT) + sizeof(void *) * offset;
- mmu_updates[0].val = pfn_to_mfn(*pt_pfn) << PAGE_SHIFT | prot_t;
+ mmu_updates[0].ptr = ((pgentry_t)prev_l_mfn << PAGE_SHIFT) +
sizeof(pgentry_t) * offset;
+ mmu_updates[0].val = (pgentry_t)pfn_to_mfn(*pt_pfn) << PAGE_SHIFT | prot_t;
if(HYPERVISOR_mmu_update(mmu_updates, 1, NULL, DOMID_SELF) < 0)
{
printk("ERROR: mmu_update failed\n");
@@ -451,16 +455,13 @@ void build_pagetable(unsigned long *star
unsigned long start_address, end_address;
unsigned long pfn_to_map, pt_pfn = *start_pfn;
static mmu_update_t mmu_updates[L1_PAGETABLE_ENTRIES + 1];
- unsigned long *tab = (unsigned long *)start_info.pt_base;
+ pgentry_t *tab = (pgentry_t *)start_info.pt_base, page;
unsigned long mfn = pfn_to_mfn(virt_to_pfn(start_info.pt_base));
- unsigned long page, offset;
+ unsigned long offset;
int count = 0;
-#if defined(__x86_64__)
- pfn_to_map = (start_info.nr_pt_frames - 3) * L1_PAGETABLE_ENTRIES;
-#else
- pfn_to_map = (start_info.nr_pt_frames - 1) * L1_PAGETABLE_ENTRIES;
-#endif
+ pfn_to_map = (start_info.nr_pt_frames - UNMAPPED_PT_FRAMES) *
L1_PAGETABLE_ENTRIES;
+
start_address = (unsigned long)pfn_to_virt(pfn_to_map);
end_address = (unsigned long)pfn_to_virt(*max_pfn);
@@ -469,7 +470,7 @@ void build_pagetable(unsigned long *star
while(start_address < end_address)
{
- tab = (unsigned long *)start_info.pt_base;
+ tab = (pgentry_t *)start_info.pt_base;
mfn = pfn_to_mfn(virt_to_pfn(start_info.pt_base));
#if defined(__x86_64__)
@@ -481,6 +482,8 @@ void build_pagetable(unsigned long *star
page = tab[offset];
mfn = pte_to_mfn(page);
tab = to_virt(mfn_to_pfn(mfn) << PAGE_SHIFT);
+#endif
+#if defined(__x86_64__) || defined(CONFIG_X86_PAE)
offset = l3_table_offset(start_address);
/* Need new L2 pt frame */
if(!(start_address & L2_MASK))
@@ -499,9 +502,9 @@ void build_pagetable(unsigned long *star
mfn = pte_to_mfn(page);
offset = l1_table_offset(start_address);
- mmu_updates[count].ptr = (mfn << PAGE_SHIFT) + sizeof(void *) * offset;
+ mmu_updates[count].ptr = ((pgentry_t)mfn << PAGE_SHIFT) +
sizeof(pgentry_t) * offset;
mmu_updates[count].val =
- pfn_to_mfn(pfn_to_map++) << PAGE_SHIFT | L1_PROT;
+ (pgentry_t)pfn_to_mfn(pfn_to_map++) << PAGE_SHIFT | L1_PROT;
count++;
if (count == L1_PAGETABLE_ENTRIES || pfn_to_map == *max_pfn)
{
@@ -558,9 +561,6 @@ void init_mm(void)
printk(" stack start: %p\n", &stack);
printk(" _end: %p\n", &_end);
- /* set up minimal memory infos */
- phys_to_machine_mapping = (unsigned long *)start_info.mfn_list;
-
/* First page follows page table pages and 3 more pages (store page etc) */
start_pfn = PFN_UP(to_phys(start_info.pt_base)) +
start_info.nr_pt_frames + 3;
@@ -570,7 +570,7 @@ void init_mm(void)
printk(" max_pfn: %lx\n", max_pfn);
build_pagetable(&start_pfn, &max_pfn);
-
+
/*
* now we can initialise the page allocator
*/
diff -r fbf676a36ee4 -r 72c5d8206d48 extras/mini-os/traps.c
--- a/extras/mini-os/traps.c Mon May 22 08:53:26 2006 -0600
+++ b/extras/mini-os/traps.c Mon May 22 14:13:38 2006 -0600
@@ -95,34 +95,47 @@ DO_ERROR(18, "machine check", machine_ch
void page_walk(unsigned long virt_address)
{
- unsigned long *tab = (unsigned long *)start_info.pt_base;
- unsigned long addr = virt_address, page;
+ pgentry_t *tab = (pgentry_t *)start_info.pt_base, page;
+ unsigned long addr = virt_address;
printk("Pagetable walk from virt %lx, base %lx:\n", virt_address,
start_info.pt_base);
#if defined(__x86_64__)
page = tab[l4_table_offset(addr)];
- tab = to_virt(mfn_to_pfn(pte_to_mfn(page)) << PAGE_SHIFT);
- printk(" L4 = %p (%p) [offset = %lx]\n", page, tab,
l4_table_offset(addr));
-
+ tab = pte_to_virt(page);
+ printk(" L4 = %"PRIpte" (%p) [offset = %lx]\n", page, tab,
l4_table_offset(addr));
+#endif
+#if defined(__x86_64__) || defined(CONFIG_X86_PAE)
page = tab[l3_table_offset(addr)];
- tab = to_virt(mfn_to_pfn(pte_to_mfn(page)) << PAGE_SHIFT);
- printk(" L3 = %p (%p) [offset = %lx]\n", page, tab,
l3_table_offset(addr));
+ tab = pte_to_virt(page);
+ printk(" L3 = %"PRIpte" (%p) [offset = %lx]\n", page, tab,
l3_table_offset(addr));
#endif
page = tab[l2_table_offset(addr)];
- tab = to_virt(mfn_to_pfn(pte_to_mfn(page)) << PAGE_SHIFT);
- printk(" L2 = %p (%p) [offset = %lx]\n", page, tab,
l2_table_offset(addr));
+ tab = pte_to_virt(page);
+ printk(" L2 = %"PRIpte" (%p) [offset = %lx]\n", page, tab,
l2_table_offset(addr));
page = tab[l1_table_offset(addr)];
- printk(" L1 = %p (%p) [offset = %lx]\n", page, tab,
l1_table_offset(addr));
+ printk(" L1 = %"PRIpte" (%p) [offset = %lx]\n", page, tab,
l1_table_offset(addr));
}
#define read_cr2() \
(HYPERVISOR_shared_info->vcpu_info[smp_processor_id()].arch.cr2)
+static int handling_pg_fault = 0;
+
void do_page_fault(struct pt_regs *regs, unsigned long error_code)
{
unsigned long addr = read_cr2();
+ /* If we are already handling a page fault, and got another one
+ that means we faulted in pagetable walk. Continuing here would cause
+ a recursive fault */
+ if(handling_pg_fault)
+ {
+ printk("Page fault in pagetable walk (access to invalid memory?).\n");
+ do_exit();
+ }
+ handling_pg_fault = 1;
+
#if defined(__x86_64__)
printk("Page fault at linear address %p, rip %p, code %lx\n",
addr, regs->rip, error_code);
@@ -130,9 +143,12 @@ void do_page_fault(struct pt_regs *regs,
printk("Page fault at linear address %p, eip %p, code %lx\n",
addr, regs->eip, error_code);
#endif
+
dump_regs(regs);
page_walk(addr);
do_exit();
+ /* We should never get here ... but still */
+ handling_pg_fault = 0;
}
void do_general_protection(struct pt_regs *regs, long error_code)
diff -r fbf676a36ee4 -r 72c5d8206d48 extras/mini-os/x86_32.S
--- a/extras/mini-os/x86_32.S Mon May 22 08:53:26 2006 -0600
+++ b/extras/mini-os/x86_32.S Mon May 22 14:13:38 2006 -0600
@@ -4,9 +4,15 @@
.section __xen_guest
.ascii "GUEST_OS=Mini-OS"
.ascii ",XEN_VER=xen-3.0"
+ .ascii ",VIRT_BASE=0xc0000000" /* &_text from minios_x86_32.lds */
+ .ascii ",ELF_PADDR_OFFSET=0xc0000000"
.ascii ",HYPERCALL_PAGE=0x2"
+#ifdef CONFIG_X86_PAE
+ .ascii ",PAE=yes"
+#else
+ .ascii ",PAE=no"
+#endif
.ascii ",LOADER=generic"
- .ascii ",PT_MODE_WRITABLE"
.byte 0
.text
diff -r fbf676a36ee4 -r 72c5d8206d48 extras/mini-os/x86_64.S
--- a/extras/mini-os/x86_64.S Mon May 22 08:53:26 2006 -0600
+++ b/extras/mini-os/x86_64.S Mon May 22 14:13:38 2006 -0600
@@ -4,9 +4,10 @@
.section __xen_guest
.ascii "GUEST_OS=Mini-OS"
.ascii ",XEN_VER=xen-3.0"
+ .ascii ",VIRT_BASE=0xffffffff80000000" /* &_text from
minios_x86_64.lds */
+ .ascii ",ELF_PADDR_OFFSET=0xffffffff80000000"
.ascii ",HYPERCALL_PAGE=0x2"
.ascii ",LOADER=generic"
- .ascii ",PT_MODE_WRITABLE"
.byte 0
.text
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/i386/kernel/fixup.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/fixup.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/fixup.c Mon May 22 14:13:38
2006 -0600
@@ -84,13 +84,3 @@ static int __init fixup_init(void)
return 0;
}
__initcall(fixup_init);
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S
--- a/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S Mon May 22 14:13:38
2006 -0600
@@ -23,6 +23,8 @@
#define X86_CAPABILITY new_cpu_data+CPUINFO_x86_capability
#define X86_VENDOR_ID new_cpu_data+CPUINFO_x86_vendor_id
+#define VIRT_ENTRY_OFFSET 0x0
+.org VIRT_ENTRY_OFFSET
ENTRY(startup_32)
movl %esi,xen_start_info
cld
@@ -155,6 +157,14 @@ ENTRY(cpu_gdt_table)
.ascii ",XEN_VER=xen-3.0"
.ascii ",VIRT_BASE=0x"
utoa __PAGE_OFFSET
+#ifdef CONFIG_XEN_COMPAT_030002
+ .ascii ",ELF_PADDR_OFFSET=0x"
+ utoa __PAGE_OFFSET
+#else
+ .ascii ",ELF_PADDR_OFFSET=0x0"
+#endif /* !CONFIG_XEN_COMPAT_030002 */
+ .ascii ",VIRT_ENTRY=0x"
+ utoa (__PAGE_OFFSET + __PHYSICAL_START + VIRT_ENTRY_OFFSET)
.ascii ",HYPERCALL_PAGE=0x"
utoa ((__PHYSICAL_START+HYPERCALL_PAGE_OFFSET)>>PAGE_SHIFT)
.ascii ",FEATURES=writable_page_tables"
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c Mon May 22
14:13:38 2006 -0600
@@ -342,13 +342,3 @@ dma_sync_single_for_device(struct device
swiotlb_sync_single_for_device(dev, dma_handle, size,
direction);
}
EXPORT_SYMBOL(dma_sync_single_for_device);
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c Mon May 22 14:13:38
2006 -0600
@@ -70,9 +70,6 @@
/* Forward Declaration. */
void __init find_max_pfn(void);
-
-/* Allows setting of maximum possible memory size */
-static unsigned long xen_override_max_pfn;
static int xen_panic_event(struct notifier_block *, unsigned long, void *);
static struct notifier_block xen_panic_block = {
@@ -399,6 +396,26 @@ start_info_t *xen_start_info;
start_info_t *xen_start_info;
EXPORT_SYMBOL(xen_start_info);
+static void __init add_memory_region(unsigned long long start,
+ unsigned long long size, int type)
+{
+ int x;
+
+ if (!efi_enabled) {
+ x = e820.nr_map;
+
+ if (x == E820MAX) {
+ printk(KERN_ERR "Ooops! Too many entries in the memory
map!\n");
+ return;
+ }
+
+ e820.map[x].addr = start;
+ e820.map[x].size = size;
+ e820.map[x].type = type;
+ e820.nr_map++;
+ }
+} /* add_memory_region */
+
static void __init limit_regions(unsigned long long size)
{
unsigned long long current_addr = 0;
@@ -442,27 +459,20 @@ static void __init limit_regions(unsigne
}
return;
}
-}
-
-static void __init add_memory_region(unsigned long long start,
- unsigned long long size, int type)
-{
- int x;
-
- if (!efi_enabled) {
- x = e820.nr_map;
-
- if (x == E820MAX) {
- printk(KERN_ERR "Ooops! Too many entries in the memory
map!\n");
- return;
- }
-
- e820.map[x].addr = start;
- e820.map[x].size = size;
- e820.map[x].type = type;
- e820.nr_map++;
- }
-} /* add_memory_region */
+#ifdef CONFIG_XEN
+ if (i==e820.nr_map && current_addr < size) {
+ /*
+ * The e820 map finished before our requested size so
+ * extend the final entry to the requested address.
+ */
+ --i;
+ if (e820.map[i].type == E820_RAM)
+ e820.map[i].size -= current_addr - size;
+ else
+ add_memory_region(current_addr, size - current_addr,
E820_RAM);
+ }
+#endif
+}
#define E820_DEBUG 1
@@ -492,7 +502,6 @@ static void __init print_memory_map(char
}
}
-#if 0
/*
* Sanitize the BIOS e820 map.
*
@@ -680,9 +689,13 @@ static int __init sanitize_e820_map(stru
*/
static int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
{
+#ifndef CONFIG_XEN
/* Only one memory region (or negative)? Ignore it */
if (nr_map < 2)
return -1;
+#else
+ BUG_ON(nr_map < 1);
+#endif
do {
unsigned long long start = biosmap->addr;
@@ -694,6 +707,7 @@ static int __init copy_e820_map(struct e
if (start > end)
return -1;
+#ifndef CONFIG_XEN
/*
* Some BIOSes claim RAM in the 640k - 1M region.
* Not right. Fix it up.
@@ -708,11 +722,11 @@ static int __init copy_e820_map(struct e
size = end - start;
}
}
+#endif
add_memory_region(start, size, type);
} while (biosmap++,--nr_map);
return 0;
}
-#endif
#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
struct edd edd;
@@ -785,13 +799,8 @@ static void __init parse_cmdline_early (
unsigned long long mem_size;
mem_size = memparse(from+4, &from);
-#if 0
limit_regions(mem_size);
userdef=1;
-#else
- xen_override_max_pfn =
- (unsigned long)(mem_size>>PAGE_SHIFT);
-#endif
}
}
@@ -984,7 +993,6 @@ static void __init parse_cmdline_early (
}
}
-#if 0 /* !XEN */
/*
* Callback for efi_memory_walk.
*/
@@ -1036,21 +1044,6 @@ void __init find_max_pfn(void)
memory_present(0, start, end);
}
}
-#else
-/* We don't use the fake e820 because we need to respond to user override. */
-void __init find_max_pfn(void)
-{
- if (xen_override_max_pfn == 0) {
- max_pfn = xen_start_info->nr_pages;
- /* Default 8MB slack (to balance backend allocations). */
- max_pfn += 8 << (20 - PAGE_SHIFT);
- } else if (xen_override_max_pfn > xen_start_info->nr_pages) {
- max_pfn = xen_override_max_pfn;
- } else {
- max_pfn = xen_start_info->nr_pages;
- }
-}
-#endif /* XEN */
/*
* Determine low and high memory ranges:
@@ -1158,6 +1151,15 @@ static void __init register_bootmem_low_
*/
last_pfn = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
+#ifdef CONFIG_XEN
+ /*
+ * Truncate to the number of actual pages currently
+ * present.
+ */
+ if (last_pfn > xen_start_info->nr_pages)
+ last_pfn = xen_start_info->nr_pages;
+#endif
+
if (last_pfn > max_low_pfn)
last_pfn = max_low_pfn;
@@ -1351,83 +1353,33 @@ void __init remapped_pgdat_init(void)
* and also for regions reported as reserved by the e820.
*/
static void __init
-legacy_init_iomem_resources(struct resource *code_resource, struct resource
*data_resource)
+legacy_init_iomem_resources(struct e820entry *e820, int nr_map,
+ struct resource *code_resource,
+ struct resource *data_resource)
{
int i;
-#ifdef CONFIG_XEN
- dom0_op_t op;
- struct dom0_memory_map_entry *map;
- unsigned long gapstart, gapsize;
- unsigned long long last;
-#endif
-
-#ifdef CONFIG_XEN_PRIVILEGED_GUEST
+
+#if defined(CONFIG_XEN_PRIVILEGED_GUEST) || !defined(CONFIG_XEN)
probe_roms();
#endif
-#ifdef CONFIG_XEN
- map = alloc_bootmem_low_pages(PAGE_SIZE);
- op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
- set_xen_guest_handle(op.u.physical_memory_map.memory_map, map);
- op.u.physical_memory_map.max_map_entries =
- PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
- BUG_ON(HYPERVISOR_dom0_op(&op));
-
- last = 0x100000000ULL;
- gapstart = 0x10000000;
- gapsize = 0x400000;
-
- for (i = op.u.physical_memory_map.nr_map_entries - 1; i >= 0; i--) {
+ for (i = 0; i < nr_map; i++) {
struct resource *res;
-
- if ((last > map[i].end) && ((last - map[i].end) > gapsize)) {
- gapsize = last - map[i].end;
- gapstart = map[i].end;
- }
- if (map[i].start < last)
- last = map[i].start;
-
- if (map[i].end > 0x100000000ULL)
+ if (e820[i].addr + e820[i].size > 0x100000000ULL)
continue;
res = alloc_bootmem_low(sizeof(struct resource));
- res->name = map[i].is_ram ? "System RAM" : "reserved";
- res->start = map[i].start;
- res->end = map[i].end - 1;
- res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
- request_resource(&iomem_resource, res);
- }
-
- free_bootmem(__pa(map), PAGE_SIZE);
-
- /*
- * Start allocating dynamic PCI memory a bit into the gap,
- * aligned up to the nearest megabyte.
- *
- * Question: should we try to pad it up a bit (do something
- * like " + (gapsize >> 3)" in there too?). We now have the
- * technology.
- */
- pci_mem_start = (gapstart + 0xfffff) & ~0xfffff;
-
- printk("Allocating PCI resources starting at %08lx (gap:
%08lx:%08lx)\n",
- pci_mem_start, gapstart, gapsize);
-#else
- for (i = 0; i < e820.nr_map; i++) {
- struct resource *res;
- if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL)
- continue;
- res = alloc_bootmem_low(sizeof(struct resource));
- switch (e820.map[i].type) {
+ switch (e820[i].type) {
case E820_RAM: res->name = "System RAM"; break;
case E820_ACPI: res->name = "ACPI Tables"; break;
case E820_NVS: res->name = "ACPI Non-volatile Storage"; break;
default: res->name = "reserved";
}
- res->start = e820.map[i].addr;
- res->end = res->start + e820.map[i].size - 1;
+ res->start = e820[i].addr;
+ res->end = res->start + e820[i].size - 1;
res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
request_resource(&iomem_resource, res);
- if (e820.map[i].type == E820_RAM) {
+#ifndef CONFIG_XEN
+ if (e820[i].type == E820_RAM) {
/*
* We don't know which RAM region contains kernel data,
* so we try it repeatedly and let the resource manager
@@ -1439,38 +1391,21 @@ legacy_init_iomem_resources(struct resou
request_resource(res, &crashk_res);
#endif
}
- }
-#endif
-}
-
-/*
- * Request address space for all standard resources
- */
-static void __init register_memory(void)
-{
-#ifndef CONFIG_XEN
+#endif
+ }
+}
+
+/*
+ * Locate a unused range of the physical address space below 4G which
+ * can be used for PCI mappings.
+ */
+static void __init
+e820_setup_gap(struct e820entry *e820, int nr_map)
+{
unsigned long gapstart, gapsize, round;
unsigned long long last;
-#endif
- int i;
-
- /* Nothing to do if not running in dom0. */
- if (!(xen_start_info->flags & SIF_INITDOMAIN))
- return;
-
- if (efi_enabled)
- efi_initialize_iomem_resources(&code_resource, &data_resource);
- else
- legacy_init_iomem_resources(&code_resource, &data_resource);
-
- /* EFI systems may still have VGA */
- request_resource(&iomem_resource, &video_ram_resource);
-
- /* request I/O space for devices used on all i[345]86 PCs */
- for (i = 0; i < STANDARD_IO_RESOURCES; i++)
- request_resource(&ioport_resource, &standard_io_resources[i]);
-
-#ifndef CONFIG_XEN
+ int i;
+
/*
* Search for the bigest gap in the low 32 bits of the e820
* memory space.
@@ -1478,10 +1413,10 @@ static void __init register_memory(void)
last = 0x100000000ull;
gapstart = 0x10000000;
gapsize = 0x400000;
- i = e820.nr_map;
+ i = nr_map;
while (--i >= 0) {
- unsigned long long start = e820.map[i].addr;
- unsigned long long end = start + e820.map[i].size;
+ unsigned long long start = e820[i].addr;
+ unsigned long long end = start + e820[i].size;
/*
* Since "last" is at most 4GB, we know we'll
@@ -1511,6 +1446,53 @@ static void __init register_memory(void)
printk("Allocating PCI resources starting at %08lx (gap:
%08lx:%08lx)\n",
pci_mem_start, gapstart, gapsize);
+}
+
+/*
+ * Request address space for all standard resources
+ */
+static void __init register_memory(void)
+{
+#ifdef CONFIG_XEN
+ struct e820entry *machine_e820;
+ struct xen_memory_map memmap;
+#endif
+ int i;
+
+ /* Nothing to do if not running in dom0. */
+ if (!(xen_start_info->flags & SIF_INITDOMAIN))
+ return;
+
+#ifdef CONFIG_XEN
+ machine_e820 = alloc_bootmem_low_pages(PAGE_SIZE);
+
+ memmap.nr_entries = E820MAX;
+ set_xen_guest_handle(memmap.buffer, machine_e820);
+
+ BUG_ON(HYPERVISOR_memory_op(XENMEM_machine_memory_map, &memmap));
+
+ legacy_init_iomem_resources(machine_e820, memmap.nr_entries,
+ &code_resource, &data_resource);
+#else
+ if (efi_enabled)
+ efi_initialize_iomem_resources(&code_resource, &data_resource);
+ else
+ legacy_init_iomem_resources(e820.map, e820.nr_map,
+ &code_resource, &data_resource);
+#endif
+
+ /* EFI systems may still have VGA */
+ request_resource(&iomem_resource, &video_ram_resource);
+
+ /* request I/O space for devices used on all i[345]86 PCs */
+ for (i = 0; i < STANDARD_IO_RESOURCES; i++)
+ request_resource(&ioport_resource, &standard_io_resources[i]);
+
+#ifdef CONFIG_XEN
+ e820_setup_gap(machine_e820, memmap.nr_entries);
+ free_bootmem(__pa(machine_e820), PAGE_SIZE);
+#else
+ e820_setup_gap(e820.map, e820.nr_map);
#endif
}
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c Mon May 22 14:13:38
2006 -0600
@@ -191,6 +191,7 @@ swiotlb_init(void)
if (swiotlb_force == 1) {
swiotlb = 1;
} else if ((swiotlb_force != -1) &&
+ is_running_on_xen() &&
(xen_start_info->flags & SIF_INITDOMAIN)) {
/* Domain 0 always has a swiotlb. */
ram_end = HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL);
@@ -662,13 +663,3 @@ EXPORT_SYMBOL(swiotlb_unmap_page);
EXPORT_SYMBOL(swiotlb_unmap_page);
EXPORT_SYMBOL(swiotlb_dma_mapping_error);
EXPORT_SYMBOL(swiotlb_dma_supported);
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c Mon May 22 14:13:38
2006 -0600
@@ -1085,13 +1085,3 @@ static int __init xen_sysctl_init(void)
return 0;
}
__initcall(xen_sysctl_init);
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c
--- a/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c Mon May 22 14:13:38
2006 -0600
@@ -412,13 +412,3 @@ int write_ldt_entry(void *ldt, int entry
mach_lp, (u64)entry_a | ((u64)entry_b<<32));
}
#endif
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/i386/mm/init-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/mm/init-xen.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/arch/i386/mm/init-xen.c Mon May 22 14:13:38
2006 -0600
@@ -228,6 +228,12 @@ static inline int page_kills_ppro(unsign
return 0;
}
+#else
+
+#define page_kills_ppro(p) 0
+
+#endif
+
extern int is_available_memory(efi_memory_desc_t *);
int page_is_ram(unsigned long pagenr)
@@ -268,13 +274,6 @@ int page_is_ram(unsigned long pagenr)
}
return 0;
}
-
-#else /* CONFIG_XEN */
-
-#define page_kills_ppro(p) 0
-#define page_is_ram(p) 1
-
-#endif
#ifdef CONFIG_HIGHMEM
pte_t *kmap_pte;
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c Mon May 22 14:13:38
2006 -0600
@@ -478,13 +478,3 @@ void __init bt_iounmap(void *addr, unsig
}
#endif /* __i386__ */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c Mon May 22 14:13:38
2006 -0600
@@ -640,13 +640,3 @@ void _arch_exit_mmap(struct mm_struct *m
(atomic_read(&mm->mm_count) == 1))
mm_unpin(mm);
}
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c
--- a/linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c Mon May 22
14:13:38 2006 -0600
@@ -141,56 +141,40 @@ xenoprof_ovf_interrupt(int irq, void * d
}
-static void unbind_virq_cpu(void * info)
-{
- int cpu = smp_processor_id();
- if (ovf_irq[cpu] >= 0) {
- unbind_from_irqhandler(ovf_irq[cpu], NULL);
- ovf_irq[cpu] = -1;
- }
-}
-
-
static void unbind_virq(void)
{
- on_each_cpu(unbind_virq_cpu, NULL, 0, 1);
-}
-
-
-int bind_virq_error;
-
-static void bind_virq_cpu(void * info)
-{
- int result;
- int cpu = smp_processor_id();
-
- result = bind_virq_to_irqhandler(VIRQ_XENOPROF,
- cpu,
- xenoprof_ovf_interrupt,
- SA_INTERRUPT,
- "xenoprof",
- NULL);
-
- if (result<0) {
- bind_virq_error = result;
- printk("xenoprof.c: binding VIRQ_XENOPROF to IRQ failed on CPU "
- "%d\n", cpu);
- } else {
- ovf_irq[cpu] = result;
+ int i;
+
+ for_each_cpu(i) {
+ if (ovf_irq[i] >= 0) {
+ unbind_from_irqhandler(ovf_irq[i], NULL);
+ ovf_irq[i] = -1;
+ }
}
}
static int bind_virq(void)
{
- bind_virq_error = 0;
- on_each_cpu(bind_virq_cpu, NULL, 0, 1);
- if (bind_virq_error) {
- unbind_virq();
- return bind_virq_error;
- } else {
- return 0;
- }
+ int i, result;
+
+ for_each_cpu(i) {
+ result = bind_virq_to_irqhandler(VIRQ_XENOPROF,
+ i,
+ xenoprof_ovf_interrupt,
+ SA_INTERRUPT,
+ "xenoprof",
+ NULL);
+
+ if (result < 0) {
+ unbind_virq();
+ return result;
+ }
+
+ ovf_irq[i] = result;
+ }
+
+ return 0;
}
@@ -305,9 +289,13 @@ static int xenoprof_set_active(int * act
for (i=0; i<adomains; i++) {
domid = active_domains[i];
+ if (domid != active_domains[i]) {
+ ret = -EINVAL;
+ goto out;
+ }
ret = HYPERVISOR_xenoprof_op(XENOPROF_set_active, &domid);
if (ret)
- return (ret);
+ goto out;
if (active_domains[i] == 0)
set_dom0 = 1;
}
@@ -316,8 +304,11 @@ static int xenoprof_set_active(int * act
domid = 0;
ret = HYPERVISOR_xenoprof_op(XENOPROF_set_active, &domid);
}
-
- active_defined = 1;
+
+out:
+ if (ret)
+ HYPERVISOR_xenoprof_op(XENOPROF_reset_active_list, NULL);
+ active_defined = !ret;
return ret;
}
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/ia64/kernel/setup.c
--- a/linux-2.6-xen-sparse/arch/ia64/kernel/setup.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/arch/ia64/kernel/setup.c Mon May 22 14:13:38
2006 -0600
@@ -514,6 +514,9 @@ setup_arch (char **cmdline_p)
#ifdef CONFIG_XEN
if (running_on_xen) {
extern shared_info_t *HYPERVISOR_shared_info;
+ extern int xen_init (void);
+
+ xen_init ();
/* xen_start_info isn't setup yet, get the flags manually */
if (HYPERVISOR_shared_info->arch.flags & SIF_INITDOMAIN) {
diff -r fbf676a36ee4 -r 72c5d8206d48 linux-2.6-xen-sparse/arch/ia64/xen/Makefile
--- a/linux-2.6-xen-sparse/arch/ia64/xen/Makefile Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/Makefile Mon May 22 14:13:38
2006 -0600
@@ -2,7 +2,7 @@
# Makefile for Xen components
#
-obj-y := hypercall.o xenivt.o xenentry.o xensetup.o xenpal.o xenhpski.o
xenconsole.o xen_ksyms.o
+obj-y := hypercall.o xenivt.o xenentry.o xensetup.o xenpal.o xenhpski.o
xenconsole.o
obj-$(CONFIG_XEN_IA64_DOM0_VP) += hypervisor.o pci-dma-xen.o util.o
-pci-dma-xen-$(CONFIG_XEN_IA64_DOM0_VP) := ../../i386/kernel/pci-dma-xen.o
\ No newline at end of file
+pci-dma-xen-$(CONFIG_XEN_IA64_DOM0_VP) := ../../i386/kernel/pci-dma-xen.o
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c
--- a/linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c Mon May 22
14:13:38 2006 -0600
@@ -11,17 +11,20 @@ shared_info_t *HYPERVISOR_shared_info =
shared_info_t *HYPERVISOR_shared_info = (shared_info_t *)XSI_BASE;
EXPORT_SYMBOL(HYPERVISOR_shared_info);
-static int initialized;
start_info_t *xen_start_info;
+
+int running_on_xen;
+EXPORT_SYMBOL(running_on_xen);
int xen_init(void)
{
+ static int initialized;
shared_info_t *s = HYPERVISOR_shared_info;
if (initialized)
return running_on_xen ? 0 : -1;
- if (!running_on_xen)
+ if (!is_running_on_xen())
return -1;
xen_start_info = __va(s->arch.start_info_pfn << PAGE_SHIFT);
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S
--- a/linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S Mon May 22 14:13:38
2006 -0600
@@ -7,12 +7,6 @@
#include <linux/config.h>
#include <asm/processor.h>
#include <asm/asmmacro.h>
-
- .data
- .align 8
- .globl running_on_xen
-running_on_xen:
- data4 0
#define isBP p3 // are we the Bootstrap Processor?
@@ -28,9 +22,3 @@ GLOBAL_ENTRY(early_xen_setup)
(p7) mov cr.iva=r10
br.ret.sptk.many rp;;
END(early_xen_setup)
-
-GLOBAL_ENTRY(is_running_on_xen)
- movl r9=running_on_xen;;
- ld4 r8=[r9]
- br.ret.sptk.many rp;;
-END(is_running_on_xen)
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c Mon May 22
14:13:38 2006 -0600
@@ -26,53 +26,34 @@
#include <asm/sections.h>
#include <xen/interface/memory.h>
-unsigned long pci_mem_start = 0xaeedbabe;
-
/*
* PFN of last memory page.
*/
unsigned long end_pfn;
EXPORT_SYMBOL(end_pfn);
-unsigned long end_user_pfn = MAXMEM>>PAGE_SHIFT;
-unsigned long end_pfn_map;
-
-/*
- * Add a memory region to the kernel e820 map.
- */
-void __init add_memory_region(unsigned long start, unsigned long size, int
type)
-{
- int x = e820.nr_map;
-
- if (x == E820MAX) {
- printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
- return;
- }
-
- e820.map[x].addr = start;
- e820.map[x].size = size;
- e820.map[x].type = type;
- e820.nr_map++;
-}
-
-#ifndef CONFIG_XEN
/*
* end_pfn only includes RAM, while end_pfn_map includes all e820 entries.
* The direct mapping extends to end_pfn_map, so that we can directly access
* apertures, ACPI and other tables without having to play with fixmaps.
*/
+unsigned long end_pfn_map;
/*
* Last pfn which the user wants to use.
*/
-
+unsigned long end_user_pfn = MAXMEM>>PAGE_SHIFT;
+
+#ifndef CONFIG_XEN
extern struct resource code_resource, data_resource;
+#endif
/* Check for some hardcoded bad areas that early boot is not allowed to touch
*/
static inline int bad_addr(unsigned long *addrp, unsigned long size)
{
unsigned long addr = *addrp, last = addr + size;
+#ifndef CONFIG_XEN
/* various gunk below that needed for SMP startup */
if (addr < 0x8000) {
*addrp = 0x8000;
@@ -100,9 +81,16 @@ static inline int bad_addr(unsigned long
return 1;
}
/* XXX ramdisk image here? */
+#else
+ if (last < (table_end<<PAGE_SHIFT)) {
+ *addrp = table_end << PAGE_SHIFT;
+ return 1;
+ }
+#endif
return 0;
}
+#ifndef CONFIG_XEN
int __init e820_mapped(unsigned long start, unsigned long end, unsigned type)
{
int i;
@@ -116,6 +104,7 @@ int __init e820_mapped(unsigned long sta
}
return 0;
}
+#endif
/*
* Find a free area in a specific range.
@@ -246,22 +235,23 @@ e820_hole_size(unsigned long start_pfn,
/*
* Mark e820 reserved areas as busy for the resource manager.
*/
-void __init e820_reserve_resources(void)
-{
- int i;
- for (i = 0; i < e820.nr_map; i++) {
+void __init e820_reserve_resources(struct e820entry *e820, int nr_map)
+{
+ int i;
+ for (i = 0; i < nr_map; i++) {
struct resource *res;
res = alloc_bootmem_low(sizeof(struct resource));
- switch (e820.map[i].type) {
+ switch (e820[i].type) {
case E820_RAM: res->name = "System RAM"; break;
case E820_ACPI: res->name = "ACPI Tables"; break;
case E820_NVS: res->name = "ACPI Non-volatile Storage"; break;
default: res->name = "reserved";
}
- res->start = e820.map[i].addr;
- res->end = res->start + e820.map[i].size - 1;
+ res->start = e820[i].addr;
+ res->end = res->start + e820[i].size - 1;
res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
request_resource(&iomem_resource, res);
+#ifndef CONFIG_XEN
if (e820.map[i].type == E820_RAM) {
/*
* We don't know which RAM region contains kernel data,
@@ -274,9 +264,27 @@ void __init e820_reserve_resources(void)
request_resource(res, &crashk_res);
#endif
}
- }
-}
-#endif /* CONFIG_XEN */
+#endif
+ }
+}
+
+/*
+ * Add a memory region to the kernel e820 map.
+ */
+void __init add_memory_region(unsigned long start, unsigned long size, int
type)
+{
+ int x = e820.nr_map;
+
+ if (x == E820MAX) {
+ printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
+ return;
+ }
+
+ e820.map[x].addr = start;
+ e820.map[x].size = size;
+ e820.map[x].type = type;
+ e820.nr_map++;
+}
void __init e820_print_map(char *who)
{
@@ -304,7 +312,6 @@ void __init e820_print_map(char *who)
}
}
-#ifndef CONFIG_XEN
/*
* Sanitize the BIOS e820 map.
*
@@ -491,9 +498,13 @@ static int __init sanitize_e820_map(stru
*/
static int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
{
+#ifndef CONFIG_XEN
/* Only one memory region (or negative)? Ignore it */
if (nr_map < 2)
return -1;
+#else
+ BUG_ON(nr_map < 1);
+#endif
do {
unsigned long start = biosmap->addr;
@@ -505,6 +516,7 @@ static int __init copy_e820_map(struct e
if (start > end)
return -1;
+#ifndef CONFIG_XEN
/*
* Some BIOSes claim RAM in the 640k - 1M region.
* Not right. Fix it up.
@@ -523,12 +535,14 @@ static int __init copy_e820_map(struct e
size = end - start;
}
}
+#endif
add_memory_region(start, size, type);
} while (biosmap++,--nr_map);
return 0;
}
+#ifndef CONFIG_XEN
void __init setup_memory_region(void)
{
char *who = "BIOS-e820";
@@ -562,104 +576,63 @@ void __init setup_memory_region(void)
#else /* CONFIG_XEN */
-extern unsigned long xen_override_max_pfn;
-extern union xen_start_info_union xen_start_info_union;
-
-unsigned long __init e820_end_of_ram(void)
-{
- unsigned long max_end_pfn;
-
- if (xen_override_max_pfn == 0) {
- max_end_pfn = xen_start_info->nr_pages;
- /* Default 8MB slack (to balance backend allocations). */
- max_end_pfn += 8 << (20 - PAGE_SHIFT);
- } else if (xen_override_max_pfn > xen_start_info->nr_pages) {
- max_end_pfn = xen_override_max_pfn;
- } else {
- max_end_pfn = xen_start_info->nr_pages;
- }
-
- return max_end_pfn;
-}
-
-unsigned long __init
-e820_hole_size(unsigned long start_pfn, unsigned long end_pfn)
-{
- return 0;
-}
-
-void __init e820_reserve_resources(void)
-{
- dom0_op_t op;
- struct dom0_memory_map_entry *map;
- unsigned long gapstart, gapsize, round, last;
- int i, found = 0;
-
- if (!(xen_start_info->flags & SIF_INITDOMAIN))
- return;
-
- map = alloc_bootmem_low_pages(PAGE_SIZE);
- op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
- set_xen_guest_handle(op.u.physical_memory_map.memory_map, map);
- op.u.physical_memory_map.max_map_entries =
- PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
- BUG_ON(HYPERVISOR_dom0_op(&op));
-
- last = 0x100000000ULL;
- gapstart = 0x10000000;
- gapsize = 0x400000;
-
- for (i = op.u.physical_memory_map.nr_map_entries - 1; i >= 0; i--) {
- struct resource *res;
-
- if ((last > map[i].end) && ((last - map[i].end) > gapsize)) {
- gapsize = last - map[i].end;
- gapstart = map[i].end;
- found = 1;
- }
- if (map[i].start < last)
- last = map[i].start;
-
- if (map[i].end > 0x100000000ULL)
- continue;
- res = alloc_bootmem_low(sizeof(struct resource));
- res->name = map[i].is_ram ? "System RAM" : "reserved";
- res->start = map[i].start;
- res->end = map[i].end - 1;
- res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
- request_resource(&iomem_resource, res);
- }
-
- free_bootmem(__pa(map), PAGE_SIZE);
-
- if (!found) {
- gapstart = HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL);
- gapstart = (gapstart << PAGE_SHIFT) + 1024*1024;
- printk(KERN_ERR "PCI: Warning: Cannot find a gap in the 32bit
address range\n"
- KERN_ERR "PCI: Unassigned devices with 32bit resource
registers may break!\n");
- }
-
+void __init setup_memory_region(void)
+{
+ int rc;
+ struct xen_memory_map memmap;
/*
- * See how much we want to round up: start off with
- * rounding to the next 1MB area.
+ * This is rather large for a stack variable but this early in
+ * the boot process we know we have plenty slack space.
*/
- round = 0x100000;
- while ((gapsize >> 4) > round)
- round += round;
- /* Fun with two's complement */
- pci_mem_start = (gapstart + round) & -round;
-
- printk(KERN_INFO "Allocating PCI resources starting at %lx (gap:
%lx:%lx)\n",
- pci_mem_start, gapstart, gapsize);
-}
-
+ struct e820entry map[E820MAX];
+
+ memmap.nr_entries = E820MAX;
+ set_xen_guest_handle(memmap.buffer, map);
+
+ rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap);
+ if ( rc == -ENOSYS ) {
+ memmap.nr_entries = 1;
+ map[0].addr = 0ULL;
+ map[0].size = xen_start_info->nr_pages << PAGE_SHIFT;
+ /* 8MB slack (to balance backend allocations). */
+ map[0].size += 8 << 20;
+ map[0].type = E820_RAM;
+ rc = 0;
+ }
+ BUG_ON(rc);
+
+ sanitize_e820_map(map, (char *)&memmap.nr_entries);
+
+ BUG_ON(copy_e820_map(map, (char)memmap.nr_entries) < 0);
+
+ printk(KERN_INFO "BIOS-provided physical RAM map:\n");
+ e820_print_map("Xen");
+}
#endif
void __init parse_memopt(char *p, char **from)
{
+ int i;
+ unsigned long current_end;
+ unsigned long end;
+
end_user_pfn = memparse(p, from);
end_user_pfn >>= PAGE_SHIFT;
- xen_override_max_pfn = (unsigned long) end_user_pfn;
+
+ end = end_user_pfn<<PAGE_SHIFT;
+ i = e820.nr_map-1;
+ current_end = e820.map[i].addr + e820.map[i].size;
+
+ if (current_end < end) {
+ /*
+ * The e820 map ends before our requested size so
+ * extend the final entry to the requested address.
+ */
+ if (e820.map[i].type == E820_RAM)
+ e820.map[i].size = end - e820.map[i].addr;
+ else
+ add_memory_region(current_end, end - current_end,
E820_RAM);
+ }
}
void __init parse_memmapopt(char *p, char **from)
@@ -683,16 +656,17 @@ void __init parse_memmapopt(char *p, cha
p = *from;
}
+unsigned long pci_mem_start = 0xaeedbabe;
+
/*
* Search for the biggest gap in the low 32 bits of the e820
* memory space. We pass this space to PCI to assign MMIO resources
* for hotplug or unconfigured devices in.
* Hopefully the BIOS let enough space left.
*/
-__init void e820_setup_gap(void)
-{
-#ifndef CONFIG_XEN
- unsigned long gapstart, gapsize;
+__init void e820_setup_gap(struct e820entry *e820, int nr_map)
+{
+ unsigned long gapstart, gapsize, round;
unsigned long last;
int i;
int found = 0;
@@ -700,10 +674,10 @@ __init void e820_setup_gap(void)
last = 0x100000000ull;
gapstart = 0x10000000;
gapsize = 0x400000;
- i = e820.nr_map;
+ i = nr_map;
while (--i >= 0) {
- unsigned long long start = e820.map[i].addr;
- unsigned long long end = start + e820.map[i].size;
+ unsigned long long start = e820[i].addr;
+ unsigned long long end = start + e820[i].size;
/*
* Since "last" is at most 4GB, we know we'll
@@ -729,16 +703,15 @@ __init void e820_setup_gap(void)
}
/*
- * Start allocating dynamic PCI memory a bit into the gap,
- * aligned up to the nearest megabyte.
- *
- * Question: should we try to pad it up a bit (do something
- * like " + (gapsize >> 3)" in there too?). We now have the
- * technology.
+ * See how much we want to round up: start off with
+ * rounding to the next 1MB area.
*/
- pci_mem_start = (gapstart + 0xfffff) & ~0xfffff;
+ round = 0x100000;
+ while ((gapsize >> 4) > round)
+ round += round;
+ /* Fun with two's complement */
+ pci_mem_start = (gapstart + round) & -round;
printk(KERN_INFO "Allocating PCI resources starting at %lx (gap:
%lx:%lx)\n",
pci_mem_start, gapstart, gapsize);
-#endif
-}
+}
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S Mon May 22
14:13:38 2006 -0600
@@ -24,6 +24,8 @@
.text
.code64
+#define VIRT_ENTRY_OFFSET 0x0
+.org VIRT_ENTRY_OFFSET
.globl startup_64
startup_64:
ENTRY(_start)
@@ -146,8 +148,18 @@ gdt_end:
.section __xen_guest
.ascii "GUEST_OS=linux,GUEST_VER=2.6"
.ascii ",XEN_VER=xen-3.0"
- .ascii ",VIRT_BASE=0x"; utoh __START_KERNEL_map
- .ascii ",HYPERCALL_PAGE=0x"; utoh (phys_hypercall_page >> PAGE_SHIFT)
+ .ascii ",VIRT_BASE=0x"
+ utoh __START_KERNEL_map
+#ifdef CONFIG_XEN_COMPAT_030002
+ .ascii ",ELF_PADDR_OFFSET=0x"
+ utoh __START_KERNEL_map
+#else
+ .ascii ",ELF_PADDR_OFFSET=0x0"
+#endif /* !CONFIG_XEN_COMPAT_030002 */
+ .ascii ",VIRT_ENTRY=0x"
+ utoh (__START_KERNEL_map + __PHYSICAL_START + VIRT_ENTRY_OFFSET)
+ .ascii ",HYPERCALL_PAGE=0x"
+ utoh (phys_hypercall_page >> PAGE_SHIFT)
.ascii ",FEATURES=writable_page_tables"
.ascii "|writable_descriptor_tables"
.ascii "|auto_translated_physmap"
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/x86_64/kernel/setup-xen.c
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/setup-xen.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/setup-xen.c Mon May 22
14:13:38 2006 -0600
@@ -76,8 +76,8 @@
#include <xen/features.h>
#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
#define PFN_PHYS(x) ((x) << PAGE_SHIFT)
-#define end_pfn_map end_pfn
#include <asm/mach-xen/setup_arch_post.h>
+#include <xen/interface/memory.h>
extern unsigned long start_pfn;
extern struct edid_info edid_info;
@@ -490,19 +490,6 @@ static __init void parse_cmdline_early (
}
#ifndef CONFIG_NUMA
-#ifdef CONFIG_XEN
-static void __init
-contig_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
-{
- unsigned long bootmap_size;
-
- bootmap_size = init_bootmem(start_pfn, end_pfn);
- free_bootmem(0, xen_start_info->nr_pages << PAGE_SHIFT);
- reserve_bootmem(HIGH_MEMORY,
- (PFN_PHYS(start_pfn) + bootmap_size + PAGE_SIZE-1)
- - HIGH_MEMORY);
-}
-#else
static void __init
contig_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
{
@@ -513,10 +500,13 @@ contig_initmem_init(unsigned long start_
if (bootmap == -1L)
panic("Cannot find bootmem map of size %ld\n",bootmap_size);
bootmap_size = init_bootmem(bootmap >> PAGE_SHIFT, end_pfn);
+#ifdef CONFIG_XEN
+ e820_bootmem_free(NODE_DATA(0), 0,
xen_start_info->nr_pages<<PAGE_SHIFT);
+#else
e820_bootmem_free(NODE_DATA(0), 0, end_pfn << PAGE_SHIFT);
+#endif
reserve_bootmem(bootmap, bootmap_size);
}
-#endif /* !CONFIG_XEN */
#endif
/* Use inline assembly to define this because the nops are defined
@@ -636,6 +626,11 @@ void __init setup_arch(char **cmdline_p)
{
unsigned long kernel_end;
+#if defined(CONFIG_XEN_PRIVILEGED_GUEST)
+ struct e820entry *machine_e820;
+ struct xen_memory_map memmap;
+#endif
+
#ifdef CONFIG_XEN
/* Register a call for panic conditions. */
notifier_chain_register(&panic_notifier_list, &xen_panic_block);
@@ -693,20 +688,18 @@ void __init setup_arch(char **cmdline_p)
rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
#endif
+#endif /* !CONFIG_XEN */
setup_memory_region();
copy_edd();
-#endif /* !CONFIG_XEN */
if (!MOUNT_ROOT_RDONLY)
root_mountflags &= ~MS_RDONLY;
init_mm.start_code = (unsigned long) &_text;
init_mm.end_code = (unsigned long) &_etext;
init_mm.end_data = (unsigned long) &_edata;
-#ifdef CONFIG_XEN
- init_mm.brk = start_pfn << PAGE_SHIFT;
-#else
- init_mm.brk = (unsigned long) &_end;
-
+ init_mm.brk = (unsigned long) &_end;
+
+#ifndef CONFIG_XEN
code_resource.start = virt_to_phys(&_text);
code_resource.end = virt_to_phys(&_etext)-1;
data_resource.start = virt_to_phys(&_etext);
@@ -735,12 +728,11 @@ void __init setup_arch(char **cmdline_p)
#endif
#ifdef CONFIG_NUMA
- numa_initmem_init(start_pfn, end_pfn);
+ numa_initmem_init(0, end_pfn);
#else
- contig_initmem_init(start_pfn, end_pfn);
-#endif
-
-#ifndef CONFIG_XEN
+ contig_initmem_init(0, end_pfn);
+#endif
+
/* Reserve direct mapping */
reserve_bootmem_generic(table_start << PAGE_SHIFT,
(table_end - table_start) << PAGE_SHIFT);
@@ -749,6 +741,10 @@ void __init setup_arch(char **cmdline_p)
kernel_end = round_up(__pa_symbol(&_end),PAGE_SIZE);
reserve_bootmem_generic(HIGH_MEMORY, kernel_end - HIGH_MEMORY);
+#ifdef CONFIG_XEN
+ /* reserve physmap, start info and initial page tables */
+ reserve_bootmem(kernel_end, (table_start<<PAGE_SHIFT)-kernel_end);
+#else
/*
* reserve physical page 0 - it's a special BIOS page on many boxes,
* enabling clean reboots, SMP operation, laptop functions.
@@ -933,13 +929,25 @@ void __init setup_arch(char **cmdline_p)
prefill_possible_map();
#endif
-#if defined(CONFIG_XEN_PRIVILEGED_GUEST) || !defined(CONFIG_XEN)
/*
* Request address space for all standard RAM and ROM resources
* and also for regions reported as reserved by the e820.
*/
+#if defined(CONFIG_XEN_PRIVILEGED_GUEST)
probe_roms();
- e820_reserve_resources();
+ if (xen_start_info->flags & SIF_INITDOMAIN) {
+ machine_e820 = alloc_bootmem_low_pages(PAGE_SIZE);
+
+ memmap.nr_entries = E820MAX;
+ set_xen_guest_handle(memmap.buffer, machine_e820);
+
+ BUG_ON(HYPERVISOR_memory_op(XENMEM_machine_memory_map,
&memmap));
+
+ e820_reserve_resources(machine_e820, memmap.nr_entries);
+ }
+#elif !defined(CONFIG_XEN)
+ probe_roms();
+ e820_reserve_resources(e820.map, e820.nr_map);
#endif
request_resource(&iomem_resource, &video_ram_resource);
@@ -951,7 +959,14 @@ void __init setup_arch(char **cmdline_p)
request_resource(&ioport_resource, &standard_io_resources[i]);
}
- e820_setup_gap();
+#if defined(CONFIG_XEN_PRIVILEGED_GUEST)
+ if (xen_start_info->flags & SIF_INITDOMAIN) {
+ e820_setup_gap(machine_e820, memmap.nr_entries);
+ free_bootmem(__pa(machine_e820), PAGE_SIZE);
+ }
+#elif !defined(CONFIG_XEN)
+ e820_setup_gap(e820.map, e820.nr_map);
+#endif
#ifdef CONFIG_GART_IOMMU
iommu_hole_init();
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/x86_64/mm/init-xen.c
--- a/linux-2.6-xen-sparse/arch/x86_64/mm/init-xen.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/arch/x86_64/mm/init-xen.c Mon May 22 14:13:38
2006 -0600
@@ -370,7 +370,7 @@ void __set_fixmap_user (enum fixed_addre
set_pte_phys(address, phys, prot, SET_FIXMAP_USER);
}
-unsigned long __initdata table_start, tables_space;
+unsigned long __initdata table_start, table_end;
unsigned long get_machine_pfn(unsigned long addr)
{
@@ -409,11 +409,17 @@ static inline int make_readonly(unsigned
{
int readonly = 0;
- /* Make old and new page tables read-only. */
+ /* Make new page tables read-only. */
+ if (!xen_feature(XENFEAT_writable_page_tables)
+ && (paddr >= (table_start << PAGE_SHIFT))
+ && (paddr < (table_end << PAGE_SHIFT)))
+ readonly = 1;
+ /* Make old page tables read-only. */
if (!xen_feature(XENFEAT_writable_page_tables)
&& (paddr >= (xen_start_info->pt_base - __START_KERNEL_map))
- && (paddr < ((table_start << PAGE_SHIFT) + tables_space)))
+ && (paddr < (start_pfn << PAGE_SHIFT)))
readonly = 1;
+
/*
* No need for writable mapping of kernel image. This also ensures that
* page and descriptor tables embedded inside don't have writable
@@ -544,7 +550,7 @@ void __init xen_init_pt(void)
mk_kernel_pgd(__pa_symbol(level3_user_pgt)));
}
-void __init extend_init_mapping(void)
+void __init extend_init_mapping(unsigned long tables_space)
{
unsigned long va = __START_KERNEL_map;
unsigned long phys, addr, *pte_page;
@@ -599,23 +605,23 @@ void __init extend_init_mapping(void)
static void __init find_early_table_space(unsigned long end)
{
- unsigned long puds, pmds, ptes;
+ unsigned long puds, pmds, ptes, tables;
puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
ptes = (end + PTE_SIZE - 1) >> PAGE_SHIFT;
- tables_space =
- round_up(puds * 8, PAGE_SIZE) +
+ tables = round_up(puds * 8, PAGE_SIZE) +
round_up(pmds * 8, PAGE_SIZE) +
round_up(ptes * 8, PAGE_SIZE);
- extend_init_mapping();
+ extend_init_mapping(tables);
table_start = start_pfn;
+ table_end = table_start + (tables>>PAGE_SHIFT);
early_printk("kernel direct mapping tables up to %lx @ %lx-%lx\n",
- end, table_start << PAGE_SHIFT, start_pfn << PAGE_SHIFT);
+ end, table_start << PAGE_SHIFT, table_end << PAGE_SHIFT);
}
/* Setup the direct mapping of the physical memory at PAGE_OFFSET.
@@ -660,7 +666,7 @@ void __meminit init_memory_mapping(unsig
set_pgd(pgd_offset_k(start), mk_kernel_pgd(pud_phys));
}
- BUG_ON(!after_bootmem && start_pfn != table_start + (tables_space >>
PAGE_SHIFT));
+ BUG_ON(!after_bootmem && start_pfn != table_end);
__flush_tlb_all();
}
@@ -1089,13 +1095,3 @@ int in_gate_area_no_task(unsigned long a
{
return (addr >= VSYSCALL_START) && (addr < VSYSCALL_END);
}
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/char/tpm/Kconfig
--- a/linux-2.6-xen-sparse/drivers/char/tpm/Kconfig Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/char/tpm/Kconfig Mon May 22 14:13:38
2006 -0600
@@ -53,10 +53,9 @@ config TCG_XEN
tristate "XEN TPM Interface"
depends on TCG_TPM && XEN
---help---
- If you want to make TPM support available to a Xen
- user domain, say Yes and it will
- be accessible from within Linux. To compile this driver
- as a module, choose M here; the module will be called
- tpm_xen.
+ If you want to make TPM support available to a Xen user domain,
+ say Yes and it will be accessible from within Linux.
+ To compile this driver as a module, choose M here; the module
+ will be called tpm_xenu.
endmenu
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/char/tpm/Makefile
--- a/linux-2.6-xen-sparse/drivers/char/tpm/Makefile Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/char/tpm/Makefile Mon May 22 14:13:38
2006 -0600
@@ -8,4 +8,5 @@ obj-$(CONFIG_TCG_NSC) += tpm_nsc.o
obj-$(CONFIG_TCG_NSC) += tpm_nsc.o
obj-$(CONFIG_TCG_ATMEL) += tpm_atmel.o
obj-$(CONFIG_TCG_INFINEON) += tpm_infineon.o
-obj-$(CONFIG_TCG_XEN) += tpm_xen.o tpm_vtpm.o
+obj-$(CONFIG_TCG_XEN) += tpm_xenu.o
+tpm_xenu-y = tpm_xen.o tpm_vtpm.o
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c
--- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c Mon May 22 14:13:38
2006 -0600
@@ -416,7 +416,7 @@ static int tpmfront_suspend(struct xenbu
*/
interruptible_sleep_on_timeout(&tp->wait_q, 100);
}
- xenbus_switch_state(dev, XenbusStateClosed);
+ xenbus_switch_state(dev, XenbusStateClosing);
if (atomic_read(&tp->tx_busy)) {
/*
@@ -745,23 +745,12 @@ failexit:
static void __exit tpmif_exit(void)
{
+ exit_tpm_xenbus();
cleanup_vtpm();
tpm_private_put();
- exit_tpm_xenbus();
gnttab_free_grant_references(gref_head);
}
module_init(tpmif_init);
-module_exit(tpmif_exit);
MODULE_LICENSE("Dual BSD/GPL");
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48 linux-2.6-xen-sparse/drivers/xen/Kconfig
--- a/linux-2.6-xen-sparse/drivers/xen/Kconfig Mon May 22 08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/Kconfig Mon May 22 14:13:38 2006 -0600
@@ -198,6 +198,22 @@ config XEN_SYSFS
help
Xen hypervisor attributes will show up under /sys/hypervisor/.
+choice
+ prompt "Xen version compatibility"
+ default XEN_COMPAT_030002_AND_LATER
+
+ config XEN_COMPAT_030002_AND_LATER
+ bool "3.0.2 and later"
+
+ config XEN_COMPAT_LATEST_ONLY
+ bool "no compatibility code"
+
+endchoice
+
+config XEN_COMPAT_030002
+ bool
+ default XEN_COMPAT_030002_AND_LATER
+
endmenu
config HAVE_ARCH_ALLOC_SKB
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c Mon May 22
14:13:38 2006 -0600
@@ -468,8 +468,8 @@ static int __init balloon_init(void)
IPRINTK("Initialising balloon driver.\n");
- if (xen_init() < 0)
- return -1;
+ if (!is_running_on_xen())
+ return -ENODEV;
current_pages = min(xen_start_info->nr_pages, max_pfn);
totalram_pages = current_pages;
@@ -603,13 +603,3 @@ EXPORT_SYMBOL_GPL(balloon_dealloc_empty_
EXPORT_SYMBOL_GPL(balloon_dealloc_empty_page_range);
MODULE_LICENSE("Dual BSD/GPL");
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c Mon May 22
14:13:38 2006 -0600
@@ -526,7 +526,7 @@ static int __init blkif_init(void)
struct page *page;
int i;
- if (xen_init() < 0)
+ if (!is_running_on_xen())
return -ENODEV;
mmap_pages = blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST;
@@ -571,27 +571,10 @@ static int __init blkif_init(void)
list_add_tail(&pending_reqs[i].free_list, &pending_free);
blkif_xenbus_init();
- __unsafe(THIS_MODULE);
+
return 0;
}
module_init(blkif_init);
-static void blkif_exit(void)
-{
- BUG();
-}
-
-module_exit(blkif_exit);
-
MODULE_LICENSE("Dual BSD/GPL");
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Mon May 22 14:13:38
2006 -0600
@@ -34,6 +34,7 @@
#include <linux/slab.h>
#include <linux/blkdev.h>
#include <linux/vmalloc.h>
+#include <linux/wait.h>
#include <asm/io.h>
#include <asm/setup.h>
#include <asm/pgalloc.h>
@@ -90,21 +91,21 @@ typedef struct blkif_st {
int st_wr_req;
int st_oo_req;
- struct work_struct free_work;
+ wait_queue_head_t waiting_to_free;
grant_handle_t shmem_handle;
grant_ref_t shmem_ref;
} blkif_t;
-blkif_t *alloc_blkif(domid_t domid);
-void free_blkif_callback(blkif_t *blkif);
+blkif_t *blkif_alloc(domid_t domid);
+void blkif_free(blkif_t *blkif);
int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn);
#define blkif_get(_b) (atomic_inc(&(_b)->refcnt))
#define blkif_put(_b) \
do { \
if (atomic_dec_and_test(&(_b)->refcnt)) \
- free_blkif_callback(_b); \
+ wake_up(&(_b)->waiting_to_free);\
} while (0)
/* Create a vbd. */
@@ -133,13 +134,3 @@ int blkif_schedule(void *arg);
int blkif_schedule(void *arg);
#endif /* __BLKIF__BACKEND__COMMON_H__ */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c Mon May 22
14:13:38 2006 -0600
@@ -35,7 +35,7 @@
static kmem_cache_t *blkif_cachep;
-blkif_t *alloc_blkif(domid_t domid)
+blkif_t *blkif_alloc(domid_t domid)
{
blkif_t *blkif;
@@ -49,6 +49,7 @@ blkif_t *alloc_blkif(domid_t domid)
atomic_set(&blkif->refcnt, 1);
init_waitqueue_head(&blkif->wq);
blkif->st_print = jiffies;
+ init_waitqueue_head(&blkif->waiting_to_free);
return blkif;
}
@@ -138,31 +139,23 @@ int blkif_map(blkif_t *blkif, unsigned l
return 0;
}
-static void free_blkif(void *arg)
+void blkif_free(blkif_t *blkif)
{
- blkif_t *blkif = (blkif_t *)arg;
+ atomic_dec(&blkif->refcnt);
+ wait_event(blkif->waiting_to_free, atomic_read(&blkif->refcnt) == 0);
/* Already disconnected? */
- if (blkif->irq) {
+ if (blkif->irq)
unbind_from_irqhandler(blkif->irq, blkif);
- blkif->irq = 0;
- }
vbd_free(&blkif->vbd);
if (blkif->blk_ring.sring) {
unmap_frontend_page(blkif);
free_vm_area(blkif->blk_ring_area);
- blkif->blk_ring.sring = NULL;
}
kmem_cache_free(blkif_cachep, blkif);
-}
-
-void free_blkif_callback(blkif_t *blkif)
-{
- INIT_WORK(&blkif->free_work, free_blkif, (void *)blkif);
- schedule_work(&blkif->free_work);
}
void __init blkif_interface_init(void)
@@ -170,13 +163,3 @@ void __init blkif_interface_init(void)
blkif_cachep = kmem_cache_create("blkif_cache", sizeof(blkif_t),
0, 0, NULL, NULL);
}
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/blkback/vbd.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/vbd.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/vbd.c Mon May 22 14:13:38
2006 -0600
@@ -55,6 +55,7 @@ int vbd_create(blkif_t *blkif, blkif_vde
unsigned minor, int readonly)
{
struct vbd *vbd;
+ struct block_device *bdev;
vbd = &blkif->vbd;
vbd->handle = handle;
@@ -63,14 +64,16 @@ int vbd_create(blkif_t *blkif, blkif_vde
vbd->pdevice = MKDEV(major, minor);
- vbd->bdev = open_by_devnum(
- vbd->pdevice,
- vbd->readonly ? FMODE_READ : FMODE_WRITE);
- if (IS_ERR(vbd->bdev)) {
- DPRINTK("vbd_creat: device %08x doesn't exist.\n",
+ bdev = open_by_devnum(vbd->pdevice,
+ vbd->readonly ? FMODE_READ : FMODE_WRITE);
+
+ if (IS_ERR(bdev)) {
+ DPRINTK("vbd_creat: device %08x could not be opened.\n",
vbd->pdevice);
return -ENOENT;
}
+
+ vbd->bdev = bdev;
if (vbd->bdev->bd_disk == NULL) {
DPRINTK("vbd_creat: device %08x doesn't exist.\n",
@@ -114,13 +117,3 @@ int vbd_translate(struct phys_req *req,
out:
return rc;
}
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Mon May 22 14:13:38
2006 -0600
@@ -108,7 +108,7 @@ static int blkback_remove(struct xenbus_
if (be->blkif) {
if (be->blkif->xenblkd)
kthread_stop(be->blkif->xenblkd);
- blkif_put(be->blkif);
+ blkif_free(be->blkif);
be->blkif = NULL;
}
@@ -140,7 +140,7 @@ static int blkback_probe(struct xenbus_d
be->dev = dev;
dev->data = be;
- be->blkif = alloc_blkif(dev->otherend_id);
+ be->blkif = blkif_alloc(dev->otherend_id);
if (IS_ERR(be->blkif)) {
err = PTR_ERR(be->blkif);
be->blkif = NULL;
@@ -408,14 +408,3 @@ void blkif_xenbus_init(void)
{
xenbus_register_backend(&blkback);
}
-
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Mon May 22
14:13:38 2006 -0600
@@ -792,7 +792,7 @@ static struct xenbus_driver blkfront = {
static int __init xlblk_init(void)
{
- if (xen_init() < 0)
+ if (!is_running_on_xen())
return -ENODEV;
return xenbus_register_frontend(&blkfront);
@@ -807,13 +807,3 @@ module_exit(xlblk_exit);
module_exit(xlblk_exit);
MODULE_LICENSE("Dual BSD/GPL");
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/blkfront/block.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h Mon May 22 14:13:38
2006 -0600
@@ -153,13 +153,3 @@ void xlvbd_del(struct blkfront_info *inf
void xlvbd_del(struct blkfront_info *info);
#endif /* __XEN_DRIVERS_BLOCK_H__ */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c Mon May 22 14:13:38
2006 -0600
@@ -315,13 +315,3 @@ xlvbd_del(struct blkfront_info *info)
blk_cleanup_queue(info->rq);
info->rq = NULL;
}
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c Mon May 22 14:13:38
2006 -0600
@@ -898,13 +898,3 @@ static int __init blkif_init(void)
}
__initcall(blkif_init);
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/blktap/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/common.h Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/common.h Mon May 22 14:13:38
2006 -0600
@@ -98,13 +98,3 @@ irqreturn_t blkif_be_int(int irq, void *
irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs);
#endif /* __BLKIF__BACKEND__COMMON_H__ */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/blktap/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c Mon May 22
14:13:38 2006 -0600
@@ -132,13 +132,3 @@ void __init blkif_interface_init(void)
blkif_cachep = kmem_cache_create(
"blkif_cache", sizeof(blkif_t), 0, 0, NULL, NULL);
}
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c Mon May 22 14:13:38
2006 -0600
@@ -221,13 +221,3 @@ void blkif_xenbus_init(void)
{
xenbus_register_backend(&blkback);
}
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48 linux-2.6-xen-sparse/drivers/xen/char/mem.c
--- a/linux-2.6-xen-sparse/drivers/xen/char/mem.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/char/mem.c Mon May 22 14:13:38
2006 -0600
@@ -180,13 +180,3 @@ struct file_operations mem_fops = {
.mmap = mmap_mem,
.open = open_mem,
};
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/console/console.c
--- a/linux-2.6-xen-sparse/drivers/xen/console/console.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c Mon May 22
14:13:38 2006 -0600
@@ -183,7 +183,7 @@ static struct console kcons_info = {
#define __RETCODE 0
static int __init xen_console_init(void)
{
- if (xen_init() < 0)
+ if (!is_running_on_xen())
return __RETCODE;
if (xen_start_info->flags & SIF_INITDOMAIN) {
@@ -566,7 +566,7 @@ static int __init xencons_init(void)
{
int rc;
- if (xen_init() < 0)
+ if (!is_running_on_xen())
return -ENODEV;
if (xc_mode == XC_OFF)
@@ -636,13 +636,3 @@ module_init(xencons_init);
module_init(xencons_init);
MODULE_LICENSE("Dual BSD/GPL");
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c
--- a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c Mon May 22
14:13:38 2006 -0600
@@ -139,13 +139,3 @@ void xencons_resume(void)
{
(void)xencons_ring_init();
}
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/core/evtchn.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c Mon May 22 14:13:38
2006 -0600
@@ -41,10 +41,10 @@
#include <asm/system.h>
#include <asm/ptrace.h>
#include <asm/synch_bitops.h>
+#include <xen/evtchn.h>
#include <xen/interface/event_channel.h>
#include <xen/interface/physdev.h>
#include <asm/hypervisor.h>
-#include <xen/evtchn.h>
#include <linux/mc146818rtc.h> /* RTC_IRQ */
/*
@@ -163,6 +163,12 @@ static inline unsigned int cpu_from_evtc
/* Upcall to generic IRQ layer. */
#ifdef CONFIG_X86
extern fastcall unsigned int do_IRQ(struct pt_regs *regs);
+void __init xen_init_IRQ(void);
+void __init init_IRQ(void)
+{
+ irq_ctx_init(0);
+ xen_init_IRQ();
+}
#if defined (__i386__)
static inline void exit_idle(void) {}
#define IRQ_REG orig_eax
@@ -804,12 +810,10 @@ void irq_resume(void)
}
}
-void __init init_IRQ(void)
+void __init xen_init_IRQ(void)
{
int i;
int cpu;
-
- irq_ctx_init(0);
spin_lock_init(&irq_mapping_update_lock);
@@ -860,13 +864,3 @@ void __init init_IRQ(void)
irq_desc[pirq_to_irq(i)].handler = &pirq_type;
}
}
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c Mon May 22 14:13:38
2006 -0600
@@ -443,7 +443,7 @@ gnttab_init(void)
{
int i;
- if (xen_init() < 0)
+ if (!is_running_on_xen())
return -ENODEV;
if (gnttab_resume() < 0)
@@ -459,13 +459,3 @@ gnttab_init(void)
}
core_initcall(gnttab_init);
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c Mon May 22
14:13:38 2006 -0600
@@ -49,6 +49,9 @@ static struct kobj_type hyp_sysfs_kobj_t
static int __init hypervisor_subsys_init(void)
{
+ if (!is_running_on_xen())
+ return -ENODEV;
+
hypervisor_subsys.kset.kobj.ktype = &hyp_sysfs_kobj_type;
return subsystem_register(&hypervisor_subsys);
}
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/core/reboot.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c Mon May 22 14:13:38
2006 -0600
@@ -369,13 +369,3 @@ static int __init setup_shutdown_event(v
}
subsys_initcall(setup_shutdown_event);
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/core/skbuff.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/skbuff.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/core/skbuff.c Mon May 22 14:13:38
2006 -0600
@@ -132,13 +132,3 @@ core_initcall(skbuff_init);
core_initcall(skbuff_init);
EXPORT_SYMBOL(__dev_alloc_skb);
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/core/smpboot.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c Mon May 22 14:13:38
2006 -0600
@@ -107,6 +107,18 @@ void __init smp_alloc_memory(void)
{
}
+static inline void
+set_cpu_sibling_map(int cpu)
+{
+ phys_proc_id[cpu] = cpu;
+ cpu_core_id[cpu] = 0;
+
+ cpu_sibling_map[cpu] = cpumask_of_cpu(cpu);
+ cpu_core_map[cpu] = cpumask_of_cpu(cpu);
+
+ cpu_data[cpu].booted_cores = 1;
+}
+
static void xen_smp_intr_init(unsigned int cpu)
{
sprintf(resched_name[cpu], "resched%d", cpu);
@@ -230,14 +242,20 @@ void __init smp_prepare_cpus(unsigned in
struct Xgt_desc_struct *gdt_descr;
#endif
+ boot_cpu_data.apicid = 0;
cpu_data[0] = boot_cpu_data;
cpu_2_logical_apicid[0] = 0;
x86_cpu_to_apicid[0] = 0;
current_thread_info()->cpu = 0;
- cpu_sibling_map[0] = cpumask_of_cpu(0);
- cpu_core_map[0] = cpumask_of_cpu(0);
+
+ for (cpu = 0; cpu < NR_CPUS; cpu++) {
+ cpus_clear(cpu_sibling_map[cpu]);
+ cpus_clear(cpu_core_map[cpu]);
+ }
+
+ set_cpu_sibling_map(0);
xen_smp_intr_init(0);
@@ -262,6 +280,8 @@ void __init smp_prepare_cpus(unsigned in
XENFEAT_writable_descriptor_tables);
cpu_data[cpu] = boot_cpu_data;
+ cpu_data[cpu].apicid = cpu;
+
cpu_2_logical_apicid[cpu] = cpu;
x86_cpu_to_apicid[cpu] = cpu;
@@ -470,6 +490,18 @@ void smp_resume(void)
vcpu_hotplug(i);
}
+static void
+remove_siblinginfo(int cpu)
+{
+ phys_proc_id[cpu] = BAD_APICID;
+ cpu_core_id[cpu] = BAD_APICID;
+
+ cpus_clear(cpu_sibling_map[cpu]);
+ cpus_clear(cpu_core_map[cpu]);
+
+ cpu_data[cpu].booted_cores = 0;
+}
+
int __cpu_disable(void)
{
cpumask_t map = cpu_online_map;
@@ -477,6 +509,8 @@ int __cpu_disable(void)
if (cpu == 0)
return -EBUSY;
+
+ remove_siblinginfo(cpu);
cpu_clear(cpu, map);
fixup_irqs(map);
@@ -549,6 +583,10 @@ int __devinit __cpu_up(unsigned int cpu)
prepare_for_smp();
#endif
+ /* This must be done before setting cpu_online_map */
+ set_cpu_sibling_map(cpu);
+ wmb();
+
xen_smp_intr_init(cpu);
cpu_set(cpu, cpu_online_map);
@@ -569,13 +607,3 @@ int setup_profiling_timer(unsigned int m
return -EINVAL;
}
#endif
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/core/xen_proc.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/xen_proc.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/core/xen_proc.c Mon May 22 14:13:38
2006 -0600
@@ -17,13 +17,3 @@ void remove_xen_proc_entry(const char *n
{
remove_proc_entry(name, xen_base);
}
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c Mon May 22 14:13:38
2006 -0600
@@ -276,7 +276,12 @@ static void xen_properties_destroy(void)
static int __init hyper_sysfs_init(void)
{
- int ret = xen_sysfs_type_init();
+ int ret;
+
+ if (!is_running_on_xen())
+ return -ENODEV;
+
+ ret = xen_sysfs_type_init();
if (ret)
goto out;
ret = xen_sysfs_version_init();
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c
--- a/linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c Mon May 22 14:13:38
2006 -0600
@@ -429,6 +429,9 @@ static int __init evtchn_init(void)
{
int err;
+ if (!is_running_on_xen())
+ return -ENODEV;
+
spin_lock_init(&port_user_lock);
memset(port_user, 0, sizeof(port_user));
@@ -453,13 +456,3 @@ module_exit(evtchn_cleanup);
module_exit(evtchn_cleanup);
MODULE_LICENSE("Dual BSD/GPL");
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/net_driver_util.c
--- a/linux-2.6-xen-sparse/drivers/xen/net_driver_util.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/net_driver_util.c Mon May 22
14:13:38 2006 -0600
@@ -56,13 +56,3 @@ int xen_net_read_mac(struct xenbus_devic
return 0;
}
EXPORT_SYMBOL_GPL(xen_net_read_mac);
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/netback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/netback/common.h Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/common.h Mon May 22 14:13:38
2006 -0600
@@ -38,6 +38,7 @@
#include <linux/in.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
+#include <linux/wait.h>
#include <xen/evtchn.h>
#include <xen/interface/io/netif.h>
#include <asm/io.h>
@@ -91,7 +92,7 @@ typedef struct netif_st {
struct net_device *dev;
struct net_device_stats stats;
- struct work_struct free_work;
+ wait_queue_head_t waiting_to_free;
} netif_t;
#define NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE)
@@ -99,8 +100,7 @@ typedef struct netif_st {
void netif_disconnect(netif_t *netif);
-netif_t *alloc_netif(domid_t domid, unsigned int handle, u8 be_mac[ETH_ALEN]);
-void free_netif(netif_t *netif);
+netif_t *netif_alloc(domid_t domid, unsigned int handle, u8 be_mac[ETH_ALEN]);
int netif_map(netif_t *netif, unsigned long tx_ring_ref,
unsigned long rx_ring_ref, unsigned int evtchn);
@@ -108,7 +108,7 @@ int netif_map(netif_t *netif, unsigned l
#define netif_put(_b) \
do { \
if ( atomic_dec_and_test(&(_b)->refcnt) ) \
- free_netif(_b); \
+ wake_up(&(_b)->waiting_to_free); \
} while (0)
void netif_xenbus_init(void);
@@ -121,13 +121,3 @@ irqreturn_t netif_be_int(int irq, void *
irqreturn_t netif_be_int(int irq, void *dev_id, struct pt_regs *regs);
#endif /* __NETIF__BACKEND__COMMON_H__ */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/netback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c Mon May 22
14:13:38 2006 -0600
@@ -78,7 +78,7 @@ static struct ethtool_ops network_ethtoo
.set_tx_csum = ethtool_op_set_tx_csum,
};
-netif_t *alloc_netif(domid_t domid, unsigned int handle, u8 be_mac[ETH_ALEN])
+netif_t *netif_alloc(domid_t domid, unsigned int handle, u8 be_mac[ETH_ALEN])
{
int err = 0, i;
struct net_device *dev;
@@ -97,7 +97,8 @@ netif_t *alloc_netif(domid_t domid, unsi
netif->domid = domid;
netif->handle = handle;
netif->status = DISCONNECTED;
- atomic_set(&netif->refcnt, 0);
+ atomic_set(&netif->refcnt, 1);
+ init_waitqueue_head(&netif->waiting_to_free);
netif->dev = dev;
netif->credit_bytes = netif->remaining_credit = ~0UL;
@@ -273,9 +274,10 @@ err_rx:
return err;
}
-static void free_netif_callback(void *arg)
-{
- netif_t *netif = (netif_t *)arg;
+static void netif_free(netif_t *netif)
+{
+ atomic_dec(&netif->refcnt);
+ wait_event(netif->waiting_to_free, atomic_read(&netif->refcnt) == 0);
if (netif->irq)
unbind_from_irqhandler(netif->irq, netif);
@@ -289,12 +291,6 @@ static void free_netif_callback(void *ar
}
free_netdev(netif->dev);
-}
-
-void free_netif(netif_t *netif)
-{
- INIT_WORK(&netif->free_work, free_netif_callback, (void *)netif);
- schedule_work(&netif->free_work);
}
void netif_disconnect(netif_t *netif)
@@ -308,22 +304,11 @@ void netif_disconnect(netif_t *netif)
__netif_down(netif);
rtnl_unlock();
netif_put(netif);
- break;
+ /* fall through */
case DISCONNECTED:
- BUG_ON(atomic_read(&netif->refcnt) != 0);
- free_netif(netif);
+ netif_free(netif);
break;
default:
BUG();
}
}
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/netback/loopback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c Mon May 22
14:13:38 2006 -0600
@@ -251,13 +251,3 @@ module_exit(loopback_exit);
module_exit(loopback_exit);
MODULE_LICENSE("Dual BSD/GPL");
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Mon May 22
14:13:38 2006 -0600
@@ -170,7 +170,9 @@ int netif_be_start_xmit(struct sk_buff *
ret = skb_copy_bits(skb, -hlen, nskb->data - hlen,
skb->len + hlen);
BUG_ON(ret);
+ /* Copy only the header fields we use in this driver. */
nskb->dev = skb->dev;
+ nskb->ip_summed = skb->ip_summed;
nskb->proto_data_valid = skb->proto_data_valid;
dev_kfree_skb(skb);
skb = nskb;
@@ -808,6 +810,9 @@ static int __init netback_init(void)
int i;
struct page *page;
+ if (!is_running_on_xen())
+ return -ENODEV;
+
/* We can increase reservation by this much in net_rx_action(). */
balloon_update_driver_allowance(NET_RX_RING_SIZE);
@@ -848,27 +853,9 @@ static int __init netback_init(void)
&netif_be_dbg);
#endif
- __unsafe(THIS_MODULE);
-
return 0;
}
-static void netback_cleanup(void)
-{
- BUG();
-}
-
module_init(netback_init);
-module_exit(netback_cleanup);
MODULE_LICENSE("Dual BSD/GPL");
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c Mon May 22 14:13:38
2006 -0600
@@ -172,7 +172,7 @@ static void backend_changed(struct xenbu
if (be->netif == NULL) {
u8 be_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
- be->netif = alloc_netif(dev->otherend_id, handle, be_mac);
+ be->netif = netif_alloc(dev->otherend_id, handle, be_mac);
if (IS_ERR(be->netif)) {
err = PTR_ERR(be->netif);
be->netif = NULL;
@@ -353,14 +353,3 @@ void netif_xenbus_init(void)
{
xenbus_register_backend(&netback);
}
-
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Mon May 22
14:13:38 2006 -0600
@@ -1,25 +1,25 @@
/******************************************************************************
* Virtual network driver for conversing with remote driver backends.
- *
+ *
* Copyright (c) 2002-2005, K A Fraser
* Copyright (c) 2005, XenSource Ltd
- *
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation; or, when distributed
* separately from the Linux kernel or incorporated into other
* software packages, subject to the following license:
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this source file (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy, modify,
* merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -43,7 +43,6 @@
#include <linux/skbuff.h>
#include <linux/init.h>
#include <linux/bitops.h>
-#include <linux/proc_fs.h>
#include <linux/ethtool.h>
#include <linux/in.h>
#include <net/sock.h>
@@ -65,8 +64,8 @@
#define GRANT_INVALID_REF 0
-#define NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE)
-#define NET_RX_RING_SIZE __RING_SIZE((netif_rx_sring_t *)0, PAGE_SIZE)
+#define NET_TX_RING_SIZE __RING_SIZE((struct netif_tx_sring *)0, PAGE_SIZE)
+#define NET_RX_RING_SIZE __RING_SIZE((struct netif_rx_sring *)0, PAGE_SIZE)
static inline void init_skb_shinfo(struct sk_buff *skb)
{
@@ -75,16 +74,14 @@ static inline void init_skb_shinfo(struc
skb_shinfo(skb)->frag_list = NULL;
}
-struct netfront_info
-{
+struct netfront_info {
struct list_head list;
struct net_device *netdev;
struct net_device_stats stats;
- unsigned int tx_full;
-
- netif_tx_front_ring_t tx;
- netif_rx_front_ring_t rx;
+
+ struct netif_tx_front_ring tx;
+ struct netif_rx_front_ring rx;
spinlock_t tx_lock;
spinlock_t rx_lock;
@@ -98,16 +95,11 @@ struct netfront_info
#define BEST_CONNECTED 2
unsigned int backend_state;
- /* Is this interface open or closed (down or up)? */
-#define UST_CLOSED 0
-#define UST_OPEN 1
- unsigned int user_state;
-
/* Receive-ring batched refills. */
#define RX_MIN_TARGET 8
#define RX_DFL_MIN_TARGET 64
#define RX_MAX_TARGET min_t(int, NET_RX_RING_SIZE, 256)
- int rx_min_target, rx_max_target, rx_target;
+ unsigned rx_min_target, rx_max_target, rx_target;
struct sk_buff_head rx_batch;
struct timer_list rx_refill_timer;
@@ -131,8 +123,8 @@ struct netfront_info
u8 mac[ETH_ALEN];
unsigned long rx_pfn_array[NET_RX_RING_SIZE];
- multicall_entry_t rx_mcl[NET_RX_RING_SIZE+1];
- mmu_update_t rx_mmu[NET_RX_RING_SIZE];
+ struct multicall_entry rx_mcl[NET_RX_RING_SIZE+1];
+ struct mmu_update rx_mmu[NET_RX_RING_SIZE];
};
/*
@@ -153,7 +145,7 @@ static inline unsigned short get_id_from
}
#ifdef DEBUG
-static char *be_state_name[] = {
+static const char *be_state_name[] = {
[BEST_CLOSED] = "closed",
[BEST_DISCONNECTED] = "disconnected",
[BEST_CONNECTED] = "connected",
@@ -170,7 +162,7 @@ static char *be_state_name[] = {
static int talk_to_backend(struct xenbus_device *, struct netfront_info *);
static int setup_device(struct xenbus_device *, struct netfront_info *);
-static int create_netdev(int, struct xenbus_device *, struct net_device **);
+static struct net_device *create_netdev(int, struct xenbus_device *);
static void netfront_closing(struct xenbus_device *);
@@ -188,16 +180,13 @@ static int send_fake_arp(struct net_devi
static irqreturn_t netif_int(int irq, void *dev_id, struct pt_regs *ptregs);
-#ifdef CONFIG_PROC_FS
-static int xennet_proc_init(void);
-static int xennet_proc_addif(struct net_device *dev);
-static void xennet_proc_delif(struct net_device *dev);
-#else
-#define xennet_proc_init() (0)
-#define xennet_proc_addif(d) (0)
-#define xennet_proc_delif(d) ((void)0)
+#ifdef CONFIG_SYSFS
+static int xennet_sysfs_addif(struct net_device *netdev);
+static void xennet_sysfs_delif(struct net_device *netdev);
+#else /* !CONFIG_SYSFS */
+#define xennet_sysfs_addif(dev) (0)
+#define xennet_sysfs_delif(dev) do { } while(0)
#endif
-
/**
* Entry point to this code when a new device is created. Allocate the basic
@@ -205,8 +194,8 @@ static void xennet_proc_delif(struct net
* inform the backend of the appropriate details for those. Switch to
* Connected state.
*/
-static int netfront_probe(struct xenbus_device *dev,
- const struct xenbus_device_id *id)
+static int __devinit netfront_probe(struct xenbus_device *dev,
+ const struct xenbus_device_id *id)
{
int err;
struct net_device *netdev;
@@ -219,8 +208,9 @@ static int netfront_probe(struct xenbus_
return err;
}
- err = create_netdev(handle, dev, &netdev);
- if (err) {
+ netdev = create_netdev(handle, dev);
+ if (IS_ERR(netdev)) {
+ err = PTR_ERR(netdev);
xenbus_dev_fatal(dev, err, "creating netdev");
return err;
}
@@ -230,7 +220,9 @@ static int netfront_probe(struct xenbus_
err = talk_to_backend(dev, info);
if (err) {
- kfree(info);
+ xennet_sysfs_delif(info->netdev);
+ unregister_netdev(netdev);
+ free_netdev(netdev);
dev->data = NULL;
return err;
}
@@ -325,8 +317,8 @@ again:
static int setup_device(struct xenbus_device *dev, struct netfront_info *info)
{
- netif_tx_sring_t *txs;
- netif_rx_sring_t *rxs;
+ struct netif_tx_sring *txs;
+ struct netif_rx_sring *rxs;
int err;
struct net_device *netdev = info->netdev;
@@ -336,13 +328,13 @@ static int setup_device(struct xenbus_de
info->tx.sring = NULL;
info->irq = 0;
- txs = (netif_tx_sring_t *)__get_free_page(GFP_KERNEL);
+ txs = (struct netif_tx_sring *)__get_free_page(GFP_KERNEL);
if (!txs) {
err = -ENOMEM;
xenbus_dev_fatal(dev, err, "allocating tx ring page");
goto fail;
}
- rxs = (netif_rx_sring_t *)__get_free_page(GFP_KERNEL);
+ rxs = (struct netif_rx_sring *)__get_free_page(GFP_KERNEL);
if (!rxs) {
err = -ENOMEM;
xenbus_dev_fatal(dev, err, "allocating rx ring page");
@@ -447,8 +439,6 @@ static int network_open(struct net_devic
memset(&np->stats, 0, sizeof(np->stats));
- np->user_state = UST_OPEN;
-
network_alloc_rx_buffers(dev);
np->rx.sring->rsp_event = np->rx.rsp_cons + 1;
@@ -457,9 +447,20 @@ static int network_open(struct net_devic
return 0;
}
+static inline void network_maybe_wake_tx(struct net_device *dev)
+{
+ struct netfront_info *np = netdev_priv(dev);
+
+ if (unlikely(netif_queue_stopped(dev)) &&
+ !RING_FULL(&np->tx) &&
+ !gnttab_empty_grant_references(&np->gref_tx_head) &&
+ likely(netif_running(dev)))
+ netif_wake_queue(dev);
+}
+
static void network_tx_buf_gc(struct net_device *dev)
{
- RING_IDX i, prod;
+ RING_IDX cons, prod;
unsigned short id;
struct netfront_info *np = netdev_priv(dev);
struct sk_buff *skb;
@@ -471,15 +472,15 @@ static void network_tx_buf_gc(struct net
prod = np->tx.sring->rsp_prod;
rmb(); /* Ensure we see responses up to 'rp'. */
- for (i = np->tx.rsp_cons; i != prod; i++) {
- id = RING_GET_RESPONSE(&np->tx, i)->id;
+ for (cons = np->tx.rsp_cons; cons != prod; cons++) {
+ id = RING_GET_RESPONSE(&np->tx, cons)->id;
skb = np->tx_skbs[id];
if (unlikely(gnttab_query_foreign_access(
np->grant_tx_ref[id]) != 0)) {
printk(KERN_ALERT "network_tx_buf_gc: warning "
"-- grant still in use by backend "
"domain.\n");
- goto out;
+ break; /* bail immediately */
}
gnttab_end_foreign_access_ref(
np->grant_tx_ref[id], GNTMAP_readonly);
@@ -503,16 +504,9 @@ static void network_tx_buf_gc(struct net
np->tx.sring->rsp_event =
prod + ((np->tx.sring->req_prod - prod) >> 1) + 1;
mb();
- } while (prod != np->tx.sring->rsp_prod);
-
- out:
- if ((np->tx_full) &&
- ((np->tx.sring->req_prod - prod) < NET_TX_RING_SIZE) &&
- !gnttab_empty_grant_references(&np->gref_tx_head)) {
- np->tx_full = 0;
- if (np->user_state == UST_OPEN)
- netif_wake_queue(dev);
- }
+ } while ((cons == prod) && (prod != np->tx.sring->rsp_prod));
+
+ network_maybe_wake_tx(dev);
}
@@ -644,18 +638,11 @@ static int network_start_xmit(struct sk_
{
unsigned short id;
struct netfront_info *np = netdev_priv(dev);
- netif_tx_request_t *tx;
+ struct netif_tx_request *tx;
RING_IDX i;
grant_ref_t ref;
unsigned long mfn;
int notify;
-
- if (unlikely(np->tx_full)) {
- printk(KERN_ALERT "%s: full queue wasn't stopped!\n",
- dev->name);
- netif_stop_queue(dev);
- goto drop;
- }
if (unlikely((((unsigned long)skb->data & ~PAGE_MASK) + skb->len) >=
PAGE_SIZE)) {
@@ -665,7 +652,10 @@ static int network_start_xmit(struct sk_
goto drop;
skb_put(nskb, skb->len);
memcpy(nskb->data, skb->data, skb->len);
+ /* Copy only the header fields we use in this driver. */
nskb->dev = skb->dev;
+ nskb->ip_summed = skb->ip_summed;
+ nskb->proto_data_valid = skb->proto_data_valid;
dev_kfree_skb(skb);
skb = nskb;
}
@@ -708,10 +698,8 @@ static int network_start_xmit(struct sk_
network_tx_buf_gc(dev);
if (RING_FULL(&np->tx) ||
- gnttab_empty_grant_references(&np->gref_tx_head)) {
- np->tx_full = 1;
+ gnttab_empty_grant_references(&np->gref_tx_head))
netif_stop_queue(dev);
- }
spin_unlock_irq(&np->tx_lock);
@@ -737,7 +725,7 @@ static irqreturn_t netif_int(int irq, vo
spin_unlock_irqrestore(&np->tx_lock, flags);
if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx) &&
- (np->user_state == UST_OPEN))
+ likely(netif_running(dev)))
netif_rx_schedule(dev);
return IRQ_HANDLED;
@@ -748,10 +736,10 @@ static int netif_poll(struct net_device
{
struct netfront_info *np = netdev_priv(dev);
struct sk_buff *skb, *nskb;
- netif_rx_response_t *rx;
+ struct netif_rx_response *rx;
RING_IDX i, rp;
- mmu_update_t *mmu = np->rx_mmu;
- multicall_entry_t *mcl = np->rx_mcl;
+ struct mmu_update *mmu = np->rx_mmu;
+ struct multicall_entry *mcl = np->rx_mcl;
int work_done, budget, more_to_do = 1;
struct sk_buff_head rxq;
unsigned long flags;
@@ -898,8 +886,11 @@ static int netif_poll(struct net_device
skb_reserve(nskb, 2);
skb_put(nskb, skb->len);
memcpy(nskb->data, skb->data, skb->len);
+ /* Copy any other fields we already set up. */
nskb->dev = skb->dev;
nskb->ip_summed = skb->ip_summed;
+ nskb->proto_data_valid = skb->proto_data_valid;
+ nskb->proto_csum_blank = skb->proto_csum_blank;
}
/* Reinitialise and then destroy the old skbuff. */
@@ -956,7 +947,6 @@ static int network_close(struct net_devi
static int network_close(struct net_device *dev)
{
struct netfront_info *np = netdev_priv(dev);
- np->user_state = UST_CLOSED;
netif_stop_queue(np->netdev);
return 0;
}
@@ -972,7 +962,7 @@ static void network_connect(struct net_d
{
struct netfront_info *np;
int i, requeue_idx;
- netif_tx_request_t *tx;
+ struct netif_tx_request *tx;
struct sk_buff *skb;
np = netdev_priv(dev);
@@ -981,11 +971,8 @@ static void network_connect(struct net_d
/* Recovery procedure: */
- /* Step 1: Reinitialise variables. */
- np->tx_full = 0;
-
/*
- * Step 2: Rebuild the RX and TX ring contents.
+ * Step 1: Rebuild the RX and TX ring contents.
* NB. We could just free the queued TX packets now but we hope
* that sending them out might do some good. We have to rebuild
* the RX ring because some of our pages are currently flipped out
@@ -1049,7 +1036,7 @@ static void network_connect(struct net_d
RING_PUSH_REQUESTS(&np->rx);
/*
- * Step 3: All public and private state should now be sane. Get
+ * Step 2: All public and private state should now be sane. Get
* ready to start sending and receiving packets and give the driver
* domain a kick because we've probably just requeued some
* packets.
@@ -1058,9 +1045,6 @@ static void network_connect(struct net_d
notify_remote_via_irq(np->irq);
network_tx_buf_gc(dev);
- if (np->user_state == UST_OPEN)
- netif_start_queue(dev);
-
spin_unlock(&np->rx_lock);
spin_unlock_irq(&np->tx_lock);
}
@@ -1072,7 +1056,7 @@ static void show_device(struct netfront_
IPRINTK("<vif handle=%u %s(%s) evtchn=%u tx=%p rx=%p>\n",
np->handle,
be_state_name[np->backend_state],
- np->user_state ? "open" : "closed",
+ netif_running(np->netdev) ? "open" : "closed",
np->evtchn,
np->tx,
np->rx);
@@ -1094,6 +1078,141 @@ static struct ethtool_ops network_ethtoo
.set_tx_csum = ethtool_op_set_tx_csum,
};
+#ifdef CONFIG_SYSFS
+static ssize_t show_rxbuf_min(struct class_device *cd, char *buf)
+{
+ struct net_device *netdev = container_of(cd, struct net_device,
+ class_dev);
+ struct netfront_info *info = netdev_priv(netdev);
+
+ return sprintf(buf, "%u\n", info->rx_min_target);
+}
+
+static ssize_t store_rxbuf_min(struct class_device *cd,
+ const char *buf, size_t len)
+{
+ struct net_device *netdev = container_of(cd, struct net_device,
+ class_dev);
+ struct netfront_info *np = netdev_priv(netdev);
+ char *endp;
+ unsigned long target;
+
+ if (!capable(CAP_NET_ADMIN))
+ return -EPERM;
+
+ target = simple_strtoul(buf, &endp, 0);
+ if (endp == buf)
+ return -EBADMSG;
+
+ if (target < RX_MIN_TARGET)
+ target = RX_MIN_TARGET;
+ if (target > RX_MAX_TARGET)
+ target = RX_MAX_TARGET;
+
+ spin_lock(&np->rx_lock);
+ if (target > np->rx_max_target)
+ np->rx_max_target = target;
+ np->rx_min_target = target;
+ if (target > np->rx_target)
+ np->rx_target = target;
+
+ network_alloc_rx_buffers(netdev);
+
+ spin_unlock(&np->rx_lock);
+ return len;
+}
+
+static ssize_t show_rxbuf_max(struct class_device *cd, char *buf)
+{
+ struct net_device *netdev = container_of(cd, struct net_device,
+ class_dev);
+ struct netfront_info *info = netdev_priv(netdev);
+
+ return sprintf(buf, "%u\n", info->rx_max_target);
+}
+
+static ssize_t store_rxbuf_max(struct class_device *cd,
+ const char *buf, size_t len)
+{
+ struct net_device *netdev = container_of(cd, struct net_device,
+ class_dev);
+ struct netfront_info *np = netdev_priv(netdev);
+ char *endp;
+ unsigned long target;
+
+ if (!capable(CAP_NET_ADMIN))
+ return -EPERM;
+
+ target = simple_strtoul(buf, &endp, 0);
+ if (endp == buf)
+ return -EBADMSG;
+
+ if (target < RX_MIN_TARGET)
+ target = RX_MIN_TARGET;
+ if (target > RX_MAX_TARGET)
+ target = RX_MAX_TARGET;
+
+ spin_lock(&np->rx_lock);
+ if (target < np->rx_min_target)
+ np->rx_min_target = target;
+ np->rx_max_target = target;
+ if (target < np->rx_target)
+ np->rx_target = target;
+
+ network_alloc_rx_buffers(netdev);
+
+ spin_unlock(&np->rx_lock);
+ return len;
+}
+
+static ssize_t show_rxbuf_cur(struct class_device *cd, char *buf)
+{
+ struct net_device *netdev = container_of(cd, struct net_device,
+ class_dev);
+ struct netfront_info *info = netdev_priv(netdev);
+
+ return sprintf(buf, "%u\n", info->rx_target);
+}
+
+static const struct class_device_attribute xennet_attrs[] = {
+ __ATTR(rxbuf_min, S_IRUGO|S_IWUSR, show_rxbuf_min, store_rxbuf_min),
+ __ATTR(rxbuf_max, S_IRUGO|S_IWUSR, show_rxbuf_max, store_rxbuf_max),
+ __ATTR(rxbuf_cur, S_IRUGO, show_rxbuf_cur, NULL),
+};
+
+static int xennet_sysfs_addif(struct net_device *netdev)
+{
+ int i;
+ int error = 0;
+
+ for (i = 0; i < ARRAY_SIZE(xennet_attrs); i++) {
+ error = class_device_create_file(&netdev->class_dev,
+ &xennet_attrs[i]);
+ if (error)
+ goto fail;
+ }
+ return 0;
+
+ fail:
+ while (--i >= 0)
+ class_device_remove_file(&netdev->class_dev,
+ &xennet_attrs[i]);
+ return error;
+}
+
+static void xennet_sysfs_delif(struct net_device *netdev)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(xennet_attrs); i++) {
+ class_device_remove_file(&netdev->class_dev,
+ &xennet_attrs[i]);
+ }
+}
+
+#endif /* CONFIG_SYSFS */
+
+
/*
* Nothing to do here. Virtual interface is point-to-point and the
* physical interface is probably promiscuous anyway.
@@ -1107,23 +1226,22 @@ static void network_set_multicast_list(s
* @param val return parameter for created device
* @return 0 on success, error code otherwise
*/
-static int create_netdev(int handle, struct xenbus_device *dev,
- struct net_device **val)
+static struct net_device * __devinit create_netdev(int handle,
+ struct xenbus_device *dev)
{
int i, err = 0;
struct net_device *netdev = NULL;
struct netfront_info *np = NULL;
- if ((netdev = alloc_etherdev(sizeof(struct netfront_info))) == NULL) {
+ netdev = alloc_etherdev(sizeof(struct netfront_info));
+ if (!netdev) {
printk(KERN_WARNING "%s> alloc_etherdev failed.\n",
__FUNCTION__);
- err = -ENOMEM;
- goto exit;
+ return ERR_PTR(-ENOMEM);
}
np = netdev_priv(netdev);
np->backend_state = BEST_CLOSED;
- np->user_state = UST_CLOSED;
np->handle = handle;
np->xbdev = dev;
@@ -1163,7 +1281,7 @@ static int create_netdev(int handle, str
printk(KERN_ALERT "#### netfront can't alloc rx grant refs\n");
gnttab_free_grant_references(np->gref_tx_head);
err = -ENOMEM;
- goto exit;
+ goto exit_free_tx;
}
netdev->open = network_open;
@@ -1180,30 +1298,32 @@ static int create_netdev(int handle, str
SET_MODULE_OWNER(netdev);
SET_NETDEV_DEV(netdev, &dev->dev);
- if ((err = register_netdev(netdev)) != 0) {
+ err = register_netdev(netdev);
+ if (err) {
printk(KERN_WARNING "%s> register_netdev err=%d\n",
__FUNCTION__, err);
- goto exit_free_grefs;
- }
-
- if ((err = xennet_proc_addif(netdev)) != 0) {
- unregister_netdev(netdev);
- goto exit_free_grefs;
+ goto exit_free_rx;
+ }
+
+ err = xennet_sysfs_addif(netdev);
+ if (err) {
+ /* This can be non-fatal: it only means no tuning parameters */
+ printk(KERN_WARNING "%s> add sysfs failed err=%d\n",
+ __FUNCTION__, err);
}
np->netdev = netdev;
+ return netdev;
+
+
+ exit_free_rx:
+ gnttab_free_grant_references(np->gref_rx_head);
+ exit_free_tx:
+ gnttab_free_grant_references(np->gref_tx_head);
exit:
- if (err != 0)
- kfree(netdev);
- else if (val != NULL)
- *val = netdev;
- return err;
-
- exit_free_grefs:
- gnttab_free_grant_references(np->gref_tx_head);
- gnttab_free_grant_references(np->gref_rx_head);
- goto exit;
+ free_netdev(netdev);
+ return ERR_PTR(err);
}
/*
@@ -1245,7 +1365,7 @@ static void netfront_closing(struct xenb
}
-static int netfront_remove(struct xenbus_device *dev)
+static int __devexit netfront_remove(struct xenbus_device *dev)
{
struct netfront_info *info = dev->data;
@@ -1260,16 +1380,9 @@ static int netfront_remove(struct xenbus
static void close_netdev(struct netfront_info *info)
{
- spin_lock_irq(&info->netdev->xmit_lock);
- netif_stop_queue(info->netdev);
- spin_unlock_irq(&info->netdev->xmit_lock);
-
-#ifdef CONFIG_PROC_FS
- xennet_proc_delif(info->netdev);
-#endif
-
del_timer_sync(&info->rx_refill_timer);
+ xennet_sysfs_delif(info->netdev);
unregister_netdev(info->netdev);
}
@@ -1325,7 +1438,7 @@ static struct xenbus_driver netfront = {
.owner = THIS_MODULE,
.ids = netfront_ids,
.probe = netfront_probe,
- .remove = netfront_remove,
+ .remove = __devexit_p(netfront_remove),
.resume = netfront_resume,
.otherend_changed = backend_changed,
};
@@ -1339,14 +1452,12 @@ static struct notifier_block notifier_in
static int __init netif_init(void)
{
- int err = 0;
+ if (!is_running_on_xen())
+ return -ENODEV;
if (xen_start_info->flags & SIF_INITDOMAIN)
return 0;
- if ((err = xennet_proc_init()) != 0)
- return err;
-
IPRINTK("Initialising virtual ethernet driver.\n");
(void)register_inetaddr_notifier(¬ifier_inetdev);
@@ -1356,7 +1467,7 @@ module_init(netif_init);
module_init(netif_init);
-static void netif_exit(void)
+static void __exit netif_exit(void)
{
unregister_inetaddr_notifier(¬ifier_inetdev);
@@ -1365,167 +1476,3 @@ module_exit(netif_exit);
module_exit(netif_exit);
MODULE_LICENSE("Dual BSD/GPL");
-
-
-/* ** /proc **/
-
-
-#ifdef CONFIG_PROC_FS
-
-#define TARGET_MIN 0UL
-#define TARGET_MAX 1UL
-#define TARGET_CUR 2UL
-
-static int xennet_proc_read(
- char *page, char **start, off_t off, int count, int *eof, void *data)
-{
- struct net_device *dev =
- (struct net_device *)((unsigned long)data & ~3UL);
- struct netfront_info *np = netdev_priv(dev);
- int len = 0, which_target = (long)data & 3;
-
- switch (which_target) {
- case TARGET_MIN:
- len = sprintf(page, "%d\n", np->rx_min_target);
- break;
- case TARGET_MAX:
- len = sprintf(page, "%d\n", np->rx_max_target);
- break;
- case TARGET_CUR:
- len = sprintf(page, "%d\n", np->rx_target);
- break;
- }
-
- *eof = 1;
- return len;
-}
-
-static int xennet_proc_write(
- struct file *file, const char __user *buffer,
- unsigned long count, void *data)
-{
- struct net_device *dev =
- (struct net_device *)((unsigned long)data & ~3UL);
- struct netfront_info *np = netdev_priv(dev);
- int which_target = (long)data & 3;
- char string[64];
- long target;
-
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- if (count <= 1)
- return -EBADMSG; /* runt */
- if (count > sizeof(string))
- return -EFBIG; /* too long */
-
- if (copy_from_user(string, buffer, count))
- return -EFAULT;
- string[sizeof(string)-1] = '\0';
-
- target = simple_strtol(string, NULL, 10);
- if (target < RX_MIN_TARGET)
- target = RX_MIN_TARGET;
- if (target > RX_MAX_TARGET)
- target = RX_MAX_TARGET;
-
- spin_lock(&np->rx_lock);
-
- switch (which_target) {
- case TARGET_MIN:
- if (target > np->rx_max_target)
- np->rx_max_target = target;
- np->rx_min_target = target;
- if (target > np->rx_target)
- np->rx_target = target;
- break;
- case TARGET_MAX:
- if (target < np->rx_min_target)
- np->rx_min_target = target;
- np->rx_max_target = target;
- if (target < np->rx_target)
- np->rx_target = target;
- break;
- case TARGET_CUR:
- break;
- }
-
- network_alloc_rx_buffers(dev);
-
- spin_unlock(&np->rx_lock);
-
- return count;
-}
-
-static int xennet_proc_init(void)
-{
- if (proc_mkdir("xen/net", NULL) == NULL)
- return -ENOMEM;
- return 0;
-}
-
-static int xennet_proc_addif(struct net_device *dev)
-{
- struct proc_dir_entry *dir, *min, *max, *cur;
- char name[30];
-
- sprintf(name, "xen/net/%s", dev->name);
-
- dir = proc_mkdir(name, NULL);
- if (!dir)
- goto nomem;
-
- min = create_proc_entry("rxbuf_min", 0644, dir);
- max = create_proc_entry("rxbuf_max", 0644, dir);
- cur = create_proc_entry("rxbuf_cur", 0444, dir);
- if (!min || !max || !cur)
- goto nomem;
-
- min->read_proc = xennet_proc_read;
- min->write_proc = xennet_proc_write;
- min->data = (void *)((unsigned long)dev | TARGET_MIN);
-
- max->read_proc = xennet_proc_read;
- max->write_proc = xennet_proc_write;
- max->data = (void *)((unsigned long)dev | TARGET_MAX);
-
- cur->read_proc = xennet_proc_read;
- cur->write_proc = xennet_proc_write;
- cur->data = (void *)((unsigned long)dev | TARGET_CUR);
-
- return 0;
-
- nomem:
- xennet_proc_delif(dev);
- return -ENOMEM;
-}
-
-static void xennet_proc_delif(struct net_device *dev)
-{
- char name[30];
-
- sprintf(name, "xen/net/%s/rxbuf_min", dev->name);
- remove_proc_entry(name, NULL);
-
- sprintf(name, "xen/net/%s/rxbuf_max", dev->name);
- remove_proc_entry(name, NULL);
-
- sprintf(name, "xen/net/%s/rxbuf_cur", dev->name);
- remove_proc_entry(name, NULL);
-
- sprintf(name, "xen/net/%s", dev->name);
- remove_proc_entry(name, NULL);
-}
-
-#endif
-
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
--- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c Mon May 22
14:13:38 2006 -0600
@@ -271,6 +271,9 @@ static int capabilities_read(char *page,
static int __init privcmd_init(void)
{
+ if (!is_running_on_xen())
+ return -ENODEV;
+
/* Set of hypercalls that privileged applications may execute. */
set_bit(__HYPERVISOR_acm_op, hypercall_permission_map);
set_bit(__HYPERVISOR_dom0_op, hypercall_permission_map);
@@ -293,13 +296,3 @@ static int __init privcmd_init(void)
}
__initcall(privcmd_init);
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/tpmback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h Mon May 22 14:13:38
2006 -0600
@@ -45,8 +45,6 @@ typedef struct tpmif_st {
long int tpm_instance;
unsigned long mmap_vstart;
- struct work_struct work;
-
grant_handle_t shmem_handle;
grant_ref_t shmem_ref;
struct page *pagerange;
@@ -82,13 +80,3 @@ extern int num_frontends;
#define MMAP_VADDR(t,_req) ((t)->mmap_vstart + ((_req) * PAGE_SIZE))
#endif /* __TPMIF__BACKEND__COMMON_H__ */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c Mon May 22
14:13:38 2006 -0600
@@ -152,10 +152,8 @@ int tpmif_map(tpmif_t *tpmif, unsigned l
return 0;
}
-static void __tpmif_disconnect_complete(void *arg)
+void tpmif_disconnect_complete(tpmif_t *tpmif)
{
- tpmif_t *tpmif = (tpmif_t *) arg;
-
if (tpmif->irq)
unbind_from_irqhandler(tpmif->irq, tpmif);
@@ -167,29 +165,13 @@ static void __tpmif_disconnect_complete(
free_tpmif(tpmif);
}
-void tpmif_disconnect_complete(tpmif_t * tpmif)
-{
- INIT_WORK(&tpmif->work, __tpmif_disconnect_complete, (void *)tpmif);
- schedule_work(&tpmif->work);
-}
-
void __init tpmif_interface_init(void)
{
tpmif_cachep = kmem_cache_create("tpmif_cache", sizeof (tpmif_t),
0, 0, NULL, NULL);
}
-void __init tpmif_interface_exit(void)
+void __exit tpmif_interface_exit(void)
{
kmem_cache_destroy(tpmif_cachep);
}
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c Mon May 22
14:13:38 2006 -0600
@@ -1063,7 +1063,7 @@ static int __init tpmback_init(void)
module_init(tpmback_init);
-static void __exit tpmback_exit(void)
+void __exit tpmback_exit(void)
{
vtpm_release_packets(NULL, 0);
tpmif_xenbus_exit();
@@ -1071,16 +1071,4 @@ static void __exit tpmback_exit(void)
misc_deregister(&vtpms_miscdevice);
}
-module_exit(tpmback_exit);
-
MODULE_LICENSE("Dual BSD/GPL");
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c Mon May 22 14:13:38
2006 -0600
@@ -150,7 +150,7 @@ static void frontend_changed(struct xenb
break;
case XenbusStateClosing:
- xenbus_switch_state(dev, XenbusStateClosing);
+ be->tpmif->tpm_instance = -1;
break;
case XenbusStateClosed:
@@ -304,13 +304,3 @@ void tpmif_xenbus_exit(void)
{
xenbus_unregister_driver(&tpmback);
}
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48 linux-2.6-xen-sparse/drivers/xen/util.c
--- a/linux-2.6-xen-sparse/drivers/xen/util.c Mon May 22 08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/util.c Mon May 22 14:13:38 2006 -0600
@@ -68,13 +68,3 @@ void unlock_vm_area(struct vm_struct *ar
preempt_enable();
}
EXPORT_SYMBOL_GPL(unlock_vm_area);
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c Mon May
22 08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c Mon May
22 14:13:38 2006 -0600
@@ -133,13 +133,3 @@ EXPORT_SYMBOL_GPL(xenbus_unmap_ring);
EXPORT_SYMBOL_GPL(xenbus_unmap_ring);
MODULE_LICENSE("Dual BSD/GPL");
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c Mon May 22
14:13:38 2006 -0600
@@ -279,14 +279,3 @@ XenbusState xenbus_read_driver_state(con
return result;
}
EXPORT_SYMBOL_GPL(xenbus_read_driver_state);
-
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c Mon May 22
14:13:38 2006 -0600
@@ -206,13 +206,3 @@ int xb_init_comms(void)
return 0;
}
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.h
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.h Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.h Mon May 22
14:13:38 2006 -0600
@@ -41,13 +41,3 @@ extern wait_queue_head_t xb_waitq;
extern wait_queue_head_t xb_waitq;
#endif /* _XENBUS_COMMS_H */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c Mon May 22
14:13:38 2006 -0600
@@ -243,13 +243,3 @@ xenbus_dev_init(void)
}
__initcall(xenbus_dev_init);
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Mon May 22
14:13:38 2006 -0600
@@ -966,10 +966,8 @@ static int __init xenbus_probe_init(void
DPRINTK("");
- if (xen_init() < 0) {
- DPRINTK("failed");
+ if (!is_running_on_xen())
return -ENODEV;
- }
/* Register ourselves with the kernel bus subsystem */
bus_register(&xenbus_frontend.bus);
@@ -1069,10 +1067,8 @@ static int __init wait_for_devices(void)
{
unsigned long timeout = jiffies + 10*HZ;
- if (xen_init() < 0) {
- DPRINTK("failed");
+ if (!is_running_on_xen())
return -ENODEV;
- }
while (time_before(jiffies, timeout)) {
if (all_devices_ready())
@@ -1085,14 +1081,3 @@ static int __init wait_for_devices(void)
}
late_initcall(wait_for_devices);
-
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c Mon May 22
14:13:38 2006 -0600
@@ -844,13 +844,3 @@ int xs_init(void)
return 0;
}
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h Mon May
22 08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h Mon May
22 14:13:38 2006 -0600
@@ -361,13 +361,3 @@ HYPERVISOR_xenoprof_op(
#endif /* __HYPERCALL_H__ */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h Mon May
22 08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h Mon May
22 14:13:38 2006 -0600
@@ -118,7 +118,7 @@ u64 jiffies_to_st(unsigned long jiffies)
#define MULTI_UVMDOMID_INDEX 4
#endif
-#define xen_init() (0)
+#define is_running_on_xen() 1
static inline int
HYPERVISOR_yield(
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h Mon May 22
14:13:38 2006 -0600
@@ -289,9 +289,10 @@ extern int page_is_ram(unsigned long pag
#endif
#define __KERNEL_START (__PAGE_OFFSET + __PHYSICAL_START)
+#ifdef CONFIG_XEN_COMPAT_030002
#undef LOAD_OFFSET
#define LOAD_OFFSET 0
-
+#endif /* CONFIG_XEN_COMPAT_030002 */
#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE)
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/include/asm-i386/mach-xen/setup_arch_post.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/setup_arch_post.h Mon May
22 08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/setup_arch_post.h Mon May
22 14:13:38 2006 -0600
@@ -10,10 +10,32 @@
static char * __init machine_specific_memory_setup(void)
{
- unsigned long max_pfn = xen_start_info->nr_pages;
+ int rc;
+ struct xen_memory_map memmap;
+ /*
+ * This is rather large for a stack variable but this early in
+ * the boot process we know we have plenty slack space.
+ */
+ struct e820entry map[E820MAX];
- e820.nr_map = 0;
- add_memory_region(0, PFN_PHYS(max_pfn), E820_RAM);
+ memmap.nr_entries = E820MAX;
+ set_xen_guest_handle(memmap.buffer, map);
+
+ rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap);
+ if ( rc == -ENOSYS ) {
+ memmap.nr_entries = 1;
+ map[0].addr = 0ULL;
+ map[0].size = xen_start_info->nr_pages << PAGE_SHIFT;
+ /* 8MB slack (to balance backend allocations). */
+ map[0].size += 8 << 20;
+ map[0].type = E820_RAM;
+ rc = 0;
+ }
+ BUG_ON(rc);
+
+ sanitize_e820_map(map, (char *)&memmap.nr_entries);
+
+ BUG_ON(copy_e820_map(map, (char)memmap.nr_entries) < 0);
return "Xen";
}
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h Mon May 22
14:13:38 2006 -0600
@@ -53,7 +53,7 @@ extern start_info_t *xen_start_info;
void force_evtchn_callback(void);
-int xen_init(void);
+#define is_running_on_xen() running_on_xen
/* Turn jiffies into Xen system time. XXX Implement me. */
#define jiffies_to_st(j) 0
@@ -158,7 +158,7 @@ xen_create_contiguous_region(unsigned lo
unsigned int order, unsigned int address_bits)
{
int ret = 0;
- if (running_on_xen) {
+ if (is_running_on_xen()) {
ret = __xen_create_contiguous_region(vstart, order,
address_bits);
}
@@ -169,7 +169,7 @@ static inline void
static inline void
xen_destroy_contiguous_region(unsigned long vstart, unsigned int order)
{
- if (running_on_xen)
+ if (is_running_on_xen())
__xen_destroy_contiguous_region(vstart, order);
}
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h Mon May 22
14:13:38 2006 -0600
@@ -42,12 +42,7 @@
#endif
#ifndef __ASSEMBLY__
-#ifdef MODULE
-extern int is_running_on_xen(void);
-#define running_on_xen (is_running_on_xen())
-#else
extern int running_on_xen;
-#endif
#define XEN_HYPER_SSM_I asm("break %0" : : "i"
(HYPERPRIVOP_SSM_I))
#define XEN_HYPER_GET_IVR asm("break %0" : : "i"
(HYPERPRIVOP_GET_IVR))
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h
--- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h Mon May
22 08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h Mon May
22 14:13:38 2006 -0600
@@ -355,19 +355,9 @@ HYPERVISOR_callback_op(
static inline int
HYPERVISOR_xenoprof_op(
- int op, unsigned long arg1, unsigned long arg2)
-{
- return _hypercall3(int, xenoprof_op, op, arg1, arg2);
+ int op, void *arg)
+{
+ return _hypercall2(int, xenoprof_op, op, arg);
}
#endif /* __HYPERCALL_H__ */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h
--- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h Mon May
22 08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h Mon May
22 14:13:38 2006 -0600
@@ -260,8 +260,10 @@ static inline pgd_t __pgd(unsigned long
#define __PAGE_OFFSET 0xffff880000000000
#endif /* !__ASSEMBLY__ */
+#ifdef CONFIG_XEN_COMPAT_030002
#undef LOAD_OFFSET
#define LOAD_OFFSET 0
+#endif /* CONFIG_XEN_COMPAT_030002 */
/* to align the pointer to the (next) page boundary */
#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
diff -r fbf676a36ee4 -r 72c5d8206d48 linux-2.6-xen-sparse/include/xen/balloon.h
--- a/linux-2.6-xen-sparse/include/xen/balloon.h Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/include/xen/balloon.h Mon May 22 14:13:38
2006 -0600
@@ -61,13 +61,3 @@ extern spinlock_t balloon_lock;
#define balloon_unlock(__flags) spin_unlock_irqrestore(&balloon_lock, __flags)
#endif /* __ASM_BALLOON_H__ */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/include/xen/driver_util.h
--- a/linux-2.6-xen-sparse/include/xen/driver_util.h Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/include/xen/driver_util.h Mon May 22 14:13:38
2006 -0600
@@ -14,13 +14,3 @@ extern void unlock_vm_area(struct vm_str
extern void unlock_vm_area(struct vm_struct *area);
#endif /* __ASM_XEN_DRIVER_UTIL_H__ */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48 linux-2.6-xen-sparse/include/xen/evtchn.h
--- a/linux-2.6-xen-sparse/include/xen/evtchn.h Mon May 22 08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/include/xen/evtchn.h Mon May 22 14:13:38 2006 -0600
@@ -112,13 +112,3 @@ extern void notify_remote_via_irq(int ir
extern void notify_remote_via_irq(int irq);
#endif /* __ASM_EVTCHN_H__ */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/include/xen/foreign_page.h
--- a/linux-2.6-xen-sparse/include/xen/foreign_page.h Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/include/xen/foreign_page.h Mon May 22 14:13:38
2006 -0600
@@ -28,13 +28,3 @@
( (void (*) (struct page *)) (page)->mapping )
#endif /* __ASM_XEN_FOREIGN_PAGE_H__ */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48 linux-2.6-xen-sparse/include/xen/gnttab.h
--- a/linux-2.6-xen-sparse/include/xen/gnttab.h Mon May 22 08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/include/xen/gnttab.h Mon May 22 14:13:38 2006 -0600
@@ -148,13 +148,3 @@ gnttab_set_unmap_op(struct gnttab_unmap_
}
#endif /* __ASM_GNTTAB_H__ */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/include/xen/net_driver_util.h
--- a/linux-2.6-xen-sparse/include/xen/net_driver_util.h Mon May 22
08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/include/xen/net_driver_util.h Mon May 22
14:13:38 2006 -0600
@@ -46,13 +46,3 @@ int xen_net_read_mac(struct xenbus_devic
#endif /* _ASM_XEN_NET_DRIVER_UTIL_H */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/include/xen/public/evtchn.h
--- a/linux-2.6-xen-sparse/include/xen/public/evtchn.h Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/include/xen/public/evtchn.h Mon May 22 14:13:38
2006 -0600
@@ -89,13 +89,3 @@ struct ioctl_evtchn_notify {
_IOC(_IOC_NONE, 'E', 5, 0)
#endif /* __LINUX_PUBLIC_EVTCHN_H__ */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/include/xen/public/privcmd.h
--- a/linux-2.6-xen-sparse/include/xen/public/privcmd.h Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/include/xen/public/privcmd.h Mon May 22 14:13:38
2006 -0600
@@ -75,13 +75,3 @@ typedef struct privcmd_mmapbatch {
_IOC(_IOC_NONE, 'P', 3, sizeof(privcmd_mmapbatch_t))
#endif /* __LINUX_PUBLIC_PRIVCMD_H__ */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48 linux-2.6-xen-sparse/include/xen/xen_proc.h
--- a/linux-2.6-xen-sparse/include/xen/xen_proc.h Mon May 22 08:53:26
2006 -0600
+++ b/linux-2.6-xen-sparse/include/xen/xen_proc.h Mon May 22 14:13:38
2006 -0600
@@ -11,13 +11,3 @@ extern void remove_xen_proc_entry(
const char *name);
#endif /* __ASM_XEN_PROC_H__ */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48 linux-2.6-xen-sparse/include/xen/xenbus.h
--- a/linux-2.6-xen-sparse/include/xen/xenbus.h Mon May 22 08:53:26 2006 -0600
+++ b/linux-2.6-xen-sparse/include/xen/xenbus.h Mon May 22 14:13:38 2006 -0600
@@ -294,13 +294,3 @@ void xenbus_dev_fatal(struct xenbus_devi
#endif /* _XEN_XENBUS_H */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
diff -r fbf676a36ee4 -r 72c5d8206d48
patches/linux-2.6.16.13/xenoprof-generic.patch
--- a/patches/linux-2.6.16.13/xenoprof-generic.patch Mon May 22 08:53:26
2006 -0600
+++ b/patches/linux-2.6.16.13/xenoprof-generic.patch Mon May 22 14:13:38
2006 -0600
@@ -225,19 +225,21 @@ diff -pruN ../pristine-linux-2.6.16.13/d
struct oprofile_operations oprofile_ops;
unsigned long oprofile_started;
-@@ -33,6 +37,17 @@ static DECLARE_MUTEX(start_sem);
+@@ -33,6 +37,19 @@ static DECLARE_MUTEX(start_sem);
*/
static int timer = 0;
-+extern unsigned int adomains;
-+extern int active_domains[MAX_OPROF_DOMAINS];
-+
-+int oprofile_set_active(void)
++int oprofile_set_active(int active_domains[], unsigned int adomains)
+{
-+ if (oprofile_ops.set_active)
-+ return oprofile_ops.set_active(active_domains, adomains);
-+
-+ return -EINVAL;
++ int err;
++
++ if (!oprofile_ops.set_active)
++ return -EINVAL;
++
++ down(&start_sem);
++ err = oprofile_ops.set_active(active_domains, adomains);
++ up(&start_sem);
++ return err;
+}
+
int oprofile_setup(void)
@@ -251,7 +253,7 @@ diff -pruN ../pristine-linux-2.6.16.13/d
int oprofile_set_backtrace(unsigned long depth);
+
-+int oprofile_set_active(void);
++int oprofile_set_active(int active_domains[], unsigned int adomains);
#endif /* OPROF_H */
diff -pruN ../pristine-linux-2.6.16.13/drivers/oprofile/oprofile_files.c
./drivers/oprofile/oprofile_files.c
@@ -280,7 +282,7 @@ diff -pruN ../pristine-linux-2.6.16.13/d
unsigned long fs_buffer_size = 131072;
unsigned long fs_cpu_buffer_size = 8192;
unsigned long fs_buffer_watershed = 32768; /* FIXME: tune */
-@@ -117,11 +123,79 @@ static ssize_t dump_write(struct file *
+@@ -117,11 +123,108 @@ static ssize_t dump_write(struct file *
static struct file_operations dump_fops = {
.write = dump_write,
};
@@ -288,63 +290,92 @@ diff -pruN ../pristine-linux-2.6.16.13/d
+
+#define TMPBUFSIZE 512
+
-+unsigned int adomains = 0;
-+long active_domains[MAX_OPROF_DOMAINS];
++static unsigned int adomains = 0;
++static int active_domains[MAX_OPROF_DOMAINS + 1];
++static DEFINE_MUTEX(adom_mutex);
+
+static ssize_t adomain_write(struct file * file, char const __user * buf,
+ size_t count, loff_t * offset)
+{
-+ char tmpbuf[TMPBUFSIZE];
-+ char * startp = tmpbuf;
-+ char * endp = tmpbuf;
++ char *tmpbuf;
++ char *startp, *endp;
+ int i;
+ unsigned long val;
++ ssize_t retval = count;
+
+ if (*offset)
+ return -EINVAL;
-+ if (!count)
-+ return 0;
+ if (count > TMPBUFSIZE - 1)
+ return -EINVAL;
+
-+ memset(tmpbuf, 0x0, TMPBUFSIZE);
-+
-+ if (copy_from_user(tmpbuf, buf, count))
++ if (!(tmpbuf = kmalloc(TMPBUFSIZE, GFP_KERNEL)))
++ return -ENOMEM;
++
++ if (copy_from_user(tmpbuf, buf, count)) {
++ kfree(tmpbuf);
+ return -EFAULT;
-+
-+ for (i = 0; i < MAX_OPROF_DOMAINS; i++)
-+ active_domains[i] = -1;
-+ adomains = 0;
-+
-+ while (1) {
-+ val = simple_strtol(startp, &endp, 0);
++ }
++ tmpbuf[count] = 0;
++
++ mutex_lock(&adom_mutex);
++
++ startp = tmpbuf;
++ /* Parse one more than MAX_OPROF_DOMAINS, for easy error checking */
++ for (i = 0; i <= MAX_OPROF_DOMAINS; i++) {
++ val = simple_strtoul(startp, &endp, 0);
+ if (endp == startp)
+ break;
-+ while (ispunct(*endp))
++ while (ispunct(*endp) || isspace(*endp))
+ endp++;
-+ active_domains[adomains++] = val;
-+ if (adomains >= MAX_OPROF_DOMAINS)
-+ break;
++ active_domains[i] = val;
++ if (active_domains[i] != val)
++ /* Overflow, force error below */
++ i = MAX_OPROF_DOMAINS + 1;
+ startp = endp;
+ }
-+ if (oprofile_set_active())
-+ return -EINVAL;
-+ return count;
++ /* Force error on trailing junk */
++ adomains = *startp ? MAX_OPROF_DOMAINS + 1 : i;
++
++ kfree(tmpbuf);
++
++ if (adomains > MAX_OPROF_DOMAINS
++ || oprofile_set_active(active_domains, adomains)) {
++ adomains = 0;
++ retval = -EINVAL;
++ }
++
++ mutex_unlock(&adom_mutex);
++ return retval;
+}
+
+static ssize_t adomain_read(struct file * file, char __user * buf,
+ size_t count, loff_t * offset)
+{
-+ char tmpbuf[TMPBUFSIZE];
-+ size_t len = 0;
++ char * tmpbuf;
++ size_t len;
+ int i;
-+ /* This is all screwed up if we run out of space */
-+ for (i = 0; i < adomains; i++)
-+ len += snprintf(tmpbuf + len, TMPBUFSIZE - len,
-+ "%u ", (unsigned int)active_domains[i]);
-+ len += snprintf(tmpbuf + len, TMPBUFSIZE - len, "\n");
-+ return simple_read_from_buffer((void __user *)buf, count,
-+ offset, tmpbuf, len);
++ ssize_t retval;
++
++ if (!(tmpbuf = kmalloc(TMPBUFSIZE, GFP_KERNEL)))
++ return -ENOMEM;
++
++ mutex_lock(&adom_mutex);
++
++ len = 0;
++ for (i = 0; i < adomains; i++)
++ len += snprintf(tmpbuf + len,
++ len < TMPBUFSIZE ? TMPBUFSIZE - len : 0,
++ "%u ", active_domains[i]);
++ WARN_ON(len > TMPBUFSIZE);
++ if (len != 0 && len <= TMPBUFSIZE)
++ tmpbuf[len-1] = '\n';
++
++ mutex_unlock(&adom_mutex);
++
++ retval = simple_read_from_buffer(buf, count, offset, tmpbuf, len);
++
++ kfree(tmpbuf);
++ return retval;
+}
+
+
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/examples/README
--- a/tools/examples/README Mon May 22 08:53:26 2006 -0600
+++ b/tools/examples/README Mon May 22 14:13:38 2006 -0600
@@ -13,6 +13,10 @@ block-common.sh - sourced by block,
block-common.sh - sourced by block, block-*
block-enbd - binds/unbinds network block devices
block-nbd - binds/unbinds network block devices
+external-device-migrate - called by xend for migrating external devices
+locking.sh - locking functions to prevent concurrent access to
+ critical sections inside script files
+logging.sh - logging function to log output using syslog
network-bridge - xen network start/stop script when using bridging
network-nat - xen network start/stop script when using NAT
network-route - xen network start/stop script when using routing
@@ -20,7 +24,14 @@ vif-common.sh - sourced by vif-bri
vif-common.sh - sourced by vif-bridge
vif-nat - xen virtual network start/stop script in NAT mode
vif-route - xen virtual network start/stop script in routed mode
-xen-backend.agent - calls block, vif-* scripts to add, remove, hotplug
+vtpm - called by xen-backend.agent to bind/unbind vTPM devices
+vtpm-addtodb - script for adding a vTPM instance to the vTPM table
+vtpm-common.sh - common code for vTPM handling
+vtpm-delete - remove an entry from the vTPM table given the
+ domain's name
+vtpm-hotplug-common.sh - sourced by vtpm
+vtpm-migration.sh - sourced by external-device-migrate
+xen-backend.agent - calls block, vif-*, vtpm scripts to add, remove, hotplug
devices
xen-backend.rules - hotplug script rules
xend-config.sxp - default xend configuration file
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/examples/external-device-migrate
--- a/tools/examples/external-device-migrate Mon May 22 08:53:26 2006 -0600
+++ b/tools/examples/external-device-migrate Mon May 22 14:13:38 2006 -0600
@@ -27,59 +27,85 @@ dir=$(dirname "$0")
. "$dir/logging.sh"
-function usage() {
- echo " Pass the following command line paremeters to the script:"
- echo ""
- echo "-step <n> : n-th migration step"
- echo "-host <host> : the destination host"
- echo "-domname <domain name> : name of the domain that is migrating"
- echo "-type <device type> : the type of device that is migrating"
- echo "-recover : indicates recovery request; an error"
- echo " occurred during migration"
- echo "-help : display this help screen"
+function ext_dev_migrate_usage() {
+cat <<EOF
+Pass the following command line parameters to the script:
+
+-step <n> : n-th migration step
+-host <host> : the destination host
+-domname <domain name> : name of the domain that is migrating
+-type <device type> : the type of device that is migrating
+-subtype <dev. subtype>: the subtype of the device
+-recover : indicates recovery request; an error
+ occurred during migration
+-help : display this help screen
+EOF
}
-while [ 1 ]; do
- if [ "$1" == "-step" ]; then
+# Parse the command line paramters. The following parameters must be
+# passed as the first ones in the sequence:
+# -step [required]
+# -host [required]
+# -domname [required]
+# -type [required]
+# -subtype [optional]
+# -recover [optional]
+# The remaining ones will be passed to the called function.
+function evaluate_params()
+{
+ local step host domname typ recover filename func stype
+ stype=""
+ while [ 1 ]; do
+ if [ "$1" == "-step" ]; then
+ shift
+ step=$1
+ elif [ "$1" == "-host" ]; then
+ shift
+ host=$1
+ elif [ "$1" == "-domname" ]; then
+ shift
+ domname=$1
+ elif [ "$1" == "-type" ]; then
+ shift
+ typ=$1
+ elif [ "$1" == "-subtype" ]; then
+ shift
+ stype="_$1"
+ elif [ "$1" == "-recover" ]; then
+ recover=1
+ elif [ "$1" == "-help" ]; then
+ ext_dev_migrate_usage
+ exit
+ else
+ break
+ fi
shift
- step=$1
- elif [ "$1" == "-host" ]; then
- shift
- host=$1
- elif [ "$1" == "-domname" ]; then
- shift
- domname=$1
- elif [ "$1" == "-type" ]; then
- shift
- typ=$1
- elif [ "$1" == "-recover" ]; then
- recover=1
- elif [ "$1" == "-help" ]; then
- usage
+ done
+
+ if [ "$step" == "" -o \
+ "$host" == "" -o \
+ "$typ" == "" -o \
+ "$domname" == "" ]; then
+ echo "Error: Parameter(s) missing (-step/-host/-type/-domname)"
+ echo ""
+ echo "$0 -help for usage."
exit
+ fi
+
+ filename="$dir/$typ$stype-migration.sh"
+ if [ ! -r $filename ]; then
+ echo "Error: Could not find script '$filename'"
+ return
+ fi
+ . "$filename"
+
+ if [ "$recover" == "1" ]; then
+ func="$typ"_recover
+ eval $func $host $domname $step $*
else
- break
+ func="$typ"_migration_step
+ eval $func $host $domname $step $*
fi
- shift
-done
+}
-if [ "$step" == "" -o \
- "$host" == "" -o \
- "$typ" == "" -o \
- "$domname" == "" ]; then
- echo "Error: Parameter(s) missing (-step/-host/-type/-domname)"
-set
- echo ""
- echo "$0 --help for usage."
- exit
-fi
-
-. "$dir/$typ-migration.sh"
-
-if [ "$recover" == "1" ]; then
- func="$typ"_recover
- eval $func $host $domname $step
-else
- func="$typ"_migration_step
- eval $func $host $domname $step
-fi
+evaluate_params $*
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/examples/network-bridge
--- a/tools/examples/network-bridge Mon May 22 08:53:26 2006 -0600
+++ b/tools/examples/network-bridge Mon May 22 14:13:38 2006 -0600
@@ -59,7 +59,7 @@ findCommand "$@"
findCommand "$@"
evalVariables "$@"
-vifnum=${vifnum:-$(ip route list | awk '/^default / { sub(/eth/,"",$NF); print
$NF }')}
+vifnum=${vifnum:-$(ip route list | awk '/^default / { print $NF }' | sed
's/^[^0-9]*//')}
bridge=${bridge:-xenbr${vifnum}}
netdev=${netdev:-eth${vifnum}}
antispoof=${antispoof:-no}
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/examples/vtpm
--- a/tools/examples/vtpm Mon May 22 08:53:26 2006 -0600
+++ b/tools/examples/vtpm Mon May 22 14:13:38 2006 -0600
@@ -23,5 +23,6 @@ if [ $vtpm_fatal_error -eq 0 ]; then
if [ $vtpm_fatal_error -eq 0 ]; then
log debug "Successful vTPM operation '$command'."
success
+else
+ fatal "Error while executing vTPM operation '$command'."
fi
-
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/examples/vtpm-common.sh
--- a/tools/examples/vtpm-common.sh Mon May 22 08:53:26 2006 -0600
+++ b/tools/examples/vtpm-common.sh Mon May 22 14:13:38 2006 -0600
@@ -64,8 +64,10 @@ fi
# Returns '0' if instance number could not be found, otherwise
# it returns the instance number in the variable 'instance'
function vtpmdb_find_instance () {
- local vmname=$1
- local ret=0
+ local vmname ret instance
+ vmname=$1
+ ret=0
+
instance=$(cat $VTPMDB | \
awk -vvmname=$vmname \
'{ \
@@ -86,8 +88,9 @@ function vtpmdb_find_instance () {
# Check whether a particular instance number is still available
# returns "0" if it is not available, "1" otherwise.
function vtpmdb_is_free_instancenum () {
- local instance=$1
- local avail=1
+ local instance instances avail i
+ instance=$1
+ avail=1
#Allowed instance number range: 1-255
if [ $instance -eq 0 -o $instance -gt 255 ]; then
avail=0
@@ -113,9 +116,7 @@ function vtpmdb_is_free_instancenum () {
# Get an available instance number given the database
# Returns an unused instance number
function vtpmdb_get_free_instancenum () {
- local ctr
- local instances
- local don
+ local ctr instances don found
instances=$(cat $VTPMDB | \
gawk \
'{ \
@@ -126,7 +127,6 @@ function vtpmdb_get_free_instancenum ()
ctr=1
don=0
while [ $don -eq 0 ]; do
- local found
found=0
for i in $instances; do
if [ $i -eq $ctr ]; then
@@ -147,8 +147,9 @@ function vtpmdb_get_free_instancenum ()
# Add a domain name and instance number to the DB file
function vtpmdb_add_instance () {
- local vmname=$1
- local inst=$2
+ local res vmname inst
+ vmname=$1
+ inst=$2
if [ ! -f $VTPMDB ]; then
echo "#Database for VM to vTPM association" > $VTPMDB
@@ -165,9 +166,10 @@ function vtpmdb_add_instance () {
#Validate whether an entry is the same as passed to this
#function
function vtpmdb_validate_entry () {
- local rc=0
- local vmname=$1
- local inst=$2
+ local res rc vmname inst
+ rc=0
+ vmname=$1
+ inst=$2
res=$(cat $VTPMDB | \
gawk -vvmname=$vmname \
@@ -188,9 +190,9 @@ function vtpmdb_validate_entry () {
}')
if [ "$res" == "1" ]; then
- let rc=1
+ rc=1
elif [ "$res" == "2" ]; then
- let rc=2
+ rc=2
fi
echo "$rc"
}
@@ -199,9 +201,11 @@ function vtpmdb_validate_entry () {
#Remove an entry from the vTPM database given its domain name
#and instance number
function vtpmdb_remove_entry () {
- local vmname=$1
- local instance=$2
- local VTPMDB_TMP="$VTPMDB".tmp
+ local vmname instance VTPMDB_TMP
+ vmname=$1
+ instance=$2
+ VTPMDB_TMP="$VTPMDB".tmp
+
$(cat $VTPMDB | \
gawk -vvmname=$vmname \
'{ \
@@ -219,13 +223,14 @@ function vtpmdb_remove_entry () {
# Find the reason for the creation of this device:
-# Set global REASON variable to 'resume' or 'create'
+# Returns 'resume' or 'create'
function vtpm_get_create_reason () {
- local resume=$(xenstore-read $XENBUS_PATH/resume)
+ local resume
+ resume=$(xenstore-read $XENBUS_PATH/resume)
if [ "$resume" == "True" ]; then
- REASON="resume"
- else
- REASON="create"
+ echo "resume"
+ else
+ echo "create"
fi
}
@@ -234,10 +239,9 @@ 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 domname=$(xenstore_read "$XENBUS_PATH"/domain)
- local res
- local instance
- vtpm_get_create_reason
+ local res instance domname reason
+ domname=$(xenstore_read "$XENBUS_PATH"/domain)
+ reason=$(vtpm_get_create_reason)
claim_lock vtpmdb
instance=$(vtpmdb_find_instance $domname)
@@ -252,20 +256,20 @@ function vtpm_create_instance () {
else
instance=$(vtpmdb_get_free_instancenum)
fi
- vtpmdb_add_instance $domname $instance
- if [ "$REASON" == "create" ]; then
+ if [ "$reason" == "create" ]; then
vtpm_create $instance
- elif [ "$REASON" == "resume" ]; then
+ else
vtpm_resume $instance $domname
- else
- #default case for 'now'
- vtpm_create $instance
+ fi
+ if [ $vtpm_fatal_error -eq 0 ]; then
+ vtpmdb_add_instance $domname $instance
fi
fi
release_lock vtpmdb
- if [ "$REASON" == "create" ]; then
+ if [ $vtpm_fatal_error -eq 0 -a \
+ "$reason" == "create" ]; then
vtpm_reset $instance
fi
xenstore_write $XENBUS_PATH/instance $instance
@@ -276,15 +280,18 @@ 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 domname=$(xenstore_read "$XENBUS_PATH"/domain)
-
- claim_lock vtpmdb
-
- instance=$(vtpmdb_find_instance $domname)
-
- if [ "$instance" != "0" ]; then
- if [ "$REASON" == "suspend" ]; then
- vtpm_suspend $instance
+ local instance reason domname
+ domname=$(xenstore_read "$XENBUS_PATH"/domain)
+
+ if [ "$doname" != "" ]; then
+ claim_lock vtpmdb
+
+ instance=$(vtpmdb_find_instance $domname)
+
+ if [ "$instance" != "0" ]; then
+ if [ "$reason" == "suspend" ]; then
+ vtpm_suspend $instance
+ fi
fi
fi
@@ -295,7 +302,7 @@ function vtpm_remove_instance () {
#Remove an entry in the VTPMDB file given the domain's name
#1st parameter: The name of the domain
function vtpm_delete_instance () {
- local rc
+ local instance
claim_lock vtpmdb
@@ -313,20 +320,21 @@ function vtpm_delete_instance () {
# "0" : this is not an address of this machine
# "1" : this is an address local to this machine
function isLocalAddress() {
- local addr=$(ping $1 -c 1 | \
- gawk '{ print substr($3,2,length($3)-2); exit }')
+ local addr res
+ addr=$(ping $1 -c 1 | \
+ gawk '{ print substr($3,2,length($3)-2); exit }')
if [ "$addr" == "" ]; then
echo "-1"
return
fi
- local res=$(ifconfig | grep "inet addr" | \
- gawk -vaddr=$addr \
- '{ \
- if ( addr == substr($2, 6)) {\
- print "1"; \
- } \
- }' \
- )
+ res=$(ifconfig | grep "inet addr" | \
+ gawk -vaddr=$addr \
+ '{ \
+ if ( addr == substr($2, 6)) {\
+ print "1"; \
+ } \
+ }' \
+ )
if [ "$res" == "" ]; then
echo "0"
return
@@ -341,7 +349,8 @@ function isLocalAddress() {
# 2nd: name of the domain to migrate
# 3rd: the migration step to perform
function vtpm_migration_step() {
- local instance=$(vtpmdb_find_instance $2)
+ local instance res
+ instance=$(vtpmdb_find_instance $2)
if [ "$instance" == "" ]; then
echo "Error: Translation of domain name ($2) to instance
failed. Check /etc/xen/vtpm.db"
log err "Error during translation of domain name"
@@ -360,6 +369,7 @@ function vtpm_migration_step() {
# 2nd: name of the domain that was to be migrated
# 3rd: the last successful migration step that was done
function vtpm_recover() {
+ local res
res=$(isLocalAddress $1)
if [ "$res" == "0" ]; then
vtpm_migrate_recover $1 $2 $3
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/examples/xmexample.hvm
--- a/tools/examples/xmexample.hvm Mon May 22 08:53:26 2006 -0600
+++ b/tools/examples/xmexample.hvm Mon May 22 14:13:38 2006 -0600
@@ -29,6 +29,10 @@ memory = 128
# A name for your domain. All domains must have different names.
name = "ExampleHVMDomain"
+
+# 128-bit UUID for the domain. The default behavior is to generate a new UUID
+# on each call to 'xm create'.
+#uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9"
#-----------------------------------------------------------------------------
# the number of cpus guest platform has, default=1
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/examples/xmexample1
--- a/tools/examples/xmexample1 Mon May 22 08:53:26 2006 -0600
+++ b/tools/examples/xmexample1 Mon May 22 14:13:38 2006 -0600
@@ -25,6 +25,10 @@ memory = 64
# A name for your domain. All domains must have different names.
name = "ExampleDomain"
+
+# 128-bit UUID for the domain. The default behavior is to generate a new UUID
+# on each call to 'xm create'.
+#uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9"
# List of which CPUS this domain is allowed to use, default Xen picks
#cpus = "" # leave to Xen to pick
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/examples/xmexample2
--- a/tools/examples/xmexample2 Mon May 22 08:53:26 2006 -0600
+++ b/tools/examples/xmexample2 Mon May 22 14:13:38 2006 -0600
@@ -54,6 +54,10 @@ memory = 64
# A name for the new domain. All domains have to have different names,
# so we use the vmid to create a name.
name = "VM%d" % vmid
+
+# 128-bit UUID for the domain. The default behavior is to generate a new UUID
+# on each call to 'xm create'.
+#uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9"
# List of which CPUS this domain is allowed to use, default Xen picks
#cpus = "" # leave to Xen to pick
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/examples/xmexample3
--- a/tools/examples/xmexample3 Mon May 22 08:53:26 2006 -0600
+++ b/tools/examples/xmexample3 Mon May 22 14:13:38 2006 -0600
@@ -54,6 +54,10 @@ memory = 64
# A name for the new domain. All domains have to have different names,
# so we use the vmid to create a name.
name = "VM%d" % vmid
+
+# 128-bit UUID for the domain. The default behavior is to generate a new UUID
+# on each call to 'xm create'.
+#uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9"
# List of which CPUS this domain is allowed to use, default Xen picks
#cpus = "" # leave to Xen to pick
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/firmware/acpi/acpi_dsdt.asl
--- a/tools/firmware/acpi/acpi_dsdt.asl Mon May 22 08:53:26 2006 -0600
+++ b/tools/firmware/acpi/acpi_dsdt.asl Mon May 22 14:13:38 2006 -0600
@@ -36,6 +36,16 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1,
Processor (CPU2, 0x02, 0x00000000, 0x00) {}
Processor (CPU3, 0x03, 0x00000000, 0x00) {}
}
+
+/* Poweroff support - ties in with qemu emulation */
+
+ Name (\_S5, Package (0x04)
+ {
+ 0x07,
+ 0x07,
+ 0x00,
+ 0x00
+ })
Scope (\_SB)
{
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/firmware/acpi/acpi_dsdt.c
--- a/tools/firmware/acpi/acpi_dsdt.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/firmware/acpi/acpi_dsdt.c Mon May 22 14:13:38 2006 -0600
@@ -1,161 +1,160 @@
/*
*
* Intel ACPI Component Architecture
- * ASL Optimizing Compiler / AML Disassembler version 20050513 [Jun 8 2005]
+ * ASL Optimizing Compiler / AML Disassembler version 20050624 [Aug 24 2005]
* Copyright (C) 2000 - 2005 Intel Corporation
* Supports ACPI Specification Revision 3.0
*
- * Compilation of "acpi_dsdt.asl" - Wed Jun 15 09:19:49 2005
+ * Compilation of "acpi_dsdt.asl" - Thu May 4 17:42:00 2006
*
* C source code output
*
*/
unsigned char AmlCode[] =
{
- 0x44,0x53,0x44,0x54,0x87,0x04,0x00,0x00, /* 00000000 "DSDT...." */
- 0x01,0x19,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */
+ 0x44,0x53,0x44,0x54,0x7C,0x04,0x00,0x00, /* 00000000 "DSDT|..." */
+ 0x01,0x72,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".rINTEL " */
0x58,0x45,0x4E,0x20,0x20,0x20,0x20,0x20, /* 00000010 "XEN " */
0x02,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
- 0x13,0x05,0x05,0x20,0x08,0x5C,0x50,0x4D, /* 00000020 "... .\PM" */
- 0x42,0x53,0x0B,0x00,0x0C,0x08,0x5C,0x50, /* 00000028 "BS....\P" */
- 0x4D,0x4C,0x4E,0x0A,0x08,0x08,0x5C,0x49, /* 00000030 "MLN...\I" */
- 0x4F,0x42,0x31,0x0A,0x00,0x08,0x5C,0x49, /* 00000038 "OB1...\I" */
- 0x4F,0x4C,0x31,0x0A,0x00,0x08,0x5C,0x41, /* 00000040 "OL1...\A" */
- 0x50,0x43,0x42,0x0C,0x00,0x00,0xC0,0xFE, /* 00000048 "PCB....." */
- 0x08,0x5C,0x41,0x50,0x43,0x4C,0x0C,0x00, /* 00000050 ".\APCL.." */
- 0x00,0x01,0x00,0x08,0x5C,0x50,0x55,0x49, /* 00000058 "....\PUI" */
- 0x44,0x0A,0x00,0x10,0x3A,0x5C,0x5F,0x50, /* 00000060 "D...:\_P" */
- 0x52,0x5F,0x5B,0x83,0x0B,0x43,0x50,0x55, /* 00000068 "R_[..CPU" */
- 0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x5B, /* 00000070 "0......[" */
- 0x83,0x0B,0x43,0x50,0x55,0x31,0x01,0x00, /* 00000078 "..CPU1.." */
- 0x00,0x00,0x00,0x00,0x5B,0x83,0x0B,0x43, /* 00000080 "....[..C" */
- 0x50,0x55,0x32,0x02,0x00,0x00,0x00,0x00, /* 00000088 "PU2....." */
- 0x00,0x5B,0x83,0x0B,0x43,0x50,0x55,0x33, /* 00000090 ".[..CPU3" */
- 0x03,0x00,0x00,0x00,0x00,0x00,0x10,0x48, /* 00000098 ".......H" */
- 0x3E,0x5C,0x5F,0x53,0x42,0x5F,0x5B,0x82, /* 000000A0 ">\_SB_[." */
- 0x4F,0x3D,0x50,0x43,0x49,0x30,0x08,0x5F, /* 000000A8 "O=PCI0._" */
- 0x48,0x49,0x44,0x0C,0x41,0xD0,0x0A,0x03, /* 000000B0 "HID.A..." */
- 0x08,0x5F,0x55,0x49,0x44,0x0A,0x00,0x08, /* 000000B8 "._UID..." */
- 0x5F,0x41,0x44,0x52,0x0A,0x00,0x08,0x5F, /* 000000C0 "_ADR..._" */
- 0x42,0x42,0x4E,0x0A,0x00,0x14,0x4A,0x06, /* 000000C8 "BBN...J." */
- 0x5F,0x43,0x52,0x53,0x00,0x08,0x50,0x52, /* 000000D0 "_CRS..PR" */
- 0x54,0x30,0x11,0x48,0x05,0x0A,0x54,0x88, /* 000000D8 "T0.H..T." */
- 0x0D,0x00,0x02,0x0F,0x00,0x00,0x00,0x00, /* 000000E0 "........" */
- 0x00,0xFF,0x00,0x00,0x00,0x00,0x01,0x47, /* 000000E8 ".......G" */
- 0x01,0xF8,0x0C,0xF8,0x0C,0x01,0x08,0x88, /* 000000F0 "........" */
- 0x0D,0x00,0x01,0x0C,0x03,0x00,0x00,0x00, /* 000000F8 "........" */
- 0x00,0xF7,0x0C,0x00,0x00,0xF8,0x0C,0x88, /* 00000100 "........" */
- 0x0D,0x00,0x01,0x0C,0x03,0x00,0x00,0x00, /* 00000108 "........" */
- 0x0D,0xFF,0x0F,0x00,0x00,0x00,0x03,0x87, /* 00000110 "........" */
- 0x17,0x00,0x00,0x0C,0x02,0x00,0x00,0x00, /* 00000118 "........" */
- 0x00,0x00,0x00,0x0A,0x00,0xFF,0xFF,0x0F, /* 00000120 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06, /* 00000128 "........" */
- 0x00,0x79,0x00,0xA4,0x50,0x52,0x54,0x30, /* 00000130 ".y..PRT0" */
- 0x08,0x41,0x49,0x52,0x30,0x12,0x47,0x05, /* 00000138 ".AIR0.G." */
- 0x06,0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x1F, /* 00000140 "........" */
- 0x00,0x0A,0x02,0x0A,0x00,0x0A,0x17,0x12, /* 00000148 "........" */
- 0x0D,0x04,0x0C,0xFF,0xFF,0x1F,0x00,0x0A, /* 00000150 "........" */
- 0x03,0x0A,0x00,0x0A,0x13,0x12,0x0D,0x04, /* 00000158 "........" */
- 0x0C,0xFF,0xFF,0x1D,0x00,0x0A,0x01,0x0A, /* 00000160 "........" */
- 0x00,0x0A,0x13,0x12,0x0D,0x04,0x0C,0xFF, /* 00000168 "........" */
- 0xFF,0x1D,0x00,0x0A,0x00,0x0A,0x00,0x0A, /* 00000170 "........" */
- 0x10,0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x1D, /* 00000178 "........" */
- 0x00,0x0A,0x02,0x0A,0x00,0x0A,0x12,0x12, /* 00000180 "........" */
- 0x0D,0x04,0x0C,0xFF,0xFF,0x1D,0x00,0x0A, /* 00000188 "........" */
- 0x03,0x0A,0x00,0x0A,0x17,0x14,0x0B,0x5F, /* 00000190 "......._" */
- 0x50,0x52,0x54,0x00,0xA4,0x41,0x49,0x52, /* 00000198 "PRT..AIR" */
- 0x30,0x5B,0x82,0x44,0x2E,0x49,0x53,0x41, /* 000001A0 "0[.D.ISA" */
- 0x5F,0x08,0x5F,0x41,0x44,0x52,0x0C,0x00, /* 000001A8 "_._ADR.." */
- 0x00,0x01,0x00,0x5B,0x82,0x47,0x0B,0x53, /* 000001B0 "...[.G.S" */
- 0x59,0x53,0x52,0x08,0x5F,0x48,0x49,0x44, /* 000001B8 "YSR._HID" */
- 0x0C,0x41,0xD0,0x0C,0x02,0x08,0x5F,0x55, /* 000001C0 ".A...._U" */
- 0x49,0x44,0x0A,0x01,0x08,0x43,0x52,0x53, /* 000001C8 "ID...CRS" */
- 0x5F,0x11,0x4E,0x08,0x0A,0x8A,0x47,0x01, /* 000001D0 "_.N...G." */
- 0x10,0x00,0x10,0x00,0x00,0x10,0x47,0x01, /* 000001D8 "......G." */
- 0x22,0x00,0x22,0x00,0x00,0x0C,0x47,0x01, /* 000001E0 ""."...G." */
- 0x30,0x00,0x30,0x00,0x00,0x10,0x47,0x01, /* 000001E8 "0.0...G." */
- 0x44,0x00,0x44,0x00,0x00,0x1C,0x47,0x01, /* 000001F0 "D.D...G." */
- 0x62,0x00,0x62,0x00,0x00,0x02,0x47,0x01, /* 000001F8 "b.b...G." */
- 0x65,0x00,0x65,0x00,0x00,0x0B,0x47,0x01, /* 00000200 "e.e...G." */
- 0x72,0x00,0x72,0x00,0x00,0x0E,0x47,0x01, /* 00000208 "r.r...G." */
- 0x80,0x00,0x80,0x00,0x00,0x01,0x47,0x01, /* 00000210 "......G." */
- 0x84,0x00,0x84,0x00,0x00,0x03,0x47,0x01, /* 00000218 "......G." */
- 0x88,0x00,0x88,0x00,0x00,0x01,0x47,0x01, /* 00000220 "......G." */
- 0x8C,0x00,0x8C,0x00,0x00,0x03,0x47,0x01, /* 00000228 "......G." */
- 0x90,0x00,0x90,0x00,0x00,0x10,0x47,0x01, /* 00000230 "......G." */
- 0xA2,0x00,0xA2,0x00,0x00,0x1C,0x47,0x01, /* 00000238 "......G." */
- 0xE0,0x00,0xE0,0x00,0x00,0x10,0x47,0x01, /* 00000240 "......G." */
- 0xA0,0x08,0xA0,0x08,0x00,0x04,0x47,0x01, /* 00000248 "......G." */
- 0xC0,0x0C,0xC0,0x0C,0x00,0x10,0x47,0x01, /* 00000250 "......G." */
- 0xD0,0x04,0xD0,0x04,0x00,0x02,0x79,0x00, /* 00000258 "......y." */
- 0x14,0x0B,0x5F,0x43,0x52,0x53,0x00,0xA4, /* 00000260 ".._CRS.." */
- 0x43,0x52,0x53,0x5F,0x5B,0x82,0x2B,0x50, /* 00000268 "CRS_[.+P" */
- 0x49,0x43,0x5F,0x08,0x5F,0x48,0x49,0x44, /* 00000270 "IC_._HID" */
- 0x0B,0x41,0xD0,0x08,0x5F,0x43,0x52,0x53, /* 00000278 ".A.._CRS" */
- 0x11,0x18,0x0A,0x15,0x47,0x01,0x20,0x00, /* 00000280 "....G. ." */
- 0x20,0x00,0x01,0x02,0x47,0x01,0xA0,0x00, /* 00000288 " ...G..." */
- 0xA0,0x00,0x01,0x02,0x22,0x04,0x00,0x79, /* 00000290 "...."..y" */
- 0x00,0x5B,0x82,0x47,0x05,0x44,0x4D,0x41, /* 00000298 ".[.G.DMA" */
- 0x30,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41, /* 000002A0 "0._HID.A" */
- 0xD0,0x02,0x00,0x08,0x5F,0x43,0x52,0x53, /* 000002A8 "...._CRS" */
- 0x11,0x41,0x04,0x0A,0x3D,0x2A,0x10,0x04, /* 000002B0 ".A..=*.." */
- 0x47,0x01,0x00,0x00,0x00,0x00,0x00,0x10, /* 000002B8 "G......." */
- 0x47,0x01,0x81,0x00,0x81,0x00,0x00,0x03, /* 000002C0 "G......." */
- 0x47,0x01,0x87,0x00,0x87,0x00,0x00,0x01, /* 000002C8 "G......." */
- 0x47,0x01,0x89,0x00,0x89,0x00,0x00,0x03, /* 000002D0 "G......." */
- 0x47,0x01,0x8F,0x00,0x8F,0x00,0x00,0x01, /* 000002D8 "G......." */
- 0x47,0x01,0xC0,0x00,0xC0,0x00,0x00,0x20, /* 000002E0 "G...... " */
- 0x47,0x01,0x80,0x04,0x80,0x04,0x00,0x10, /* 000002E8 "G......." */
- 0x79,0x00,0x5B,0x82,0x25,0x54,0x4D,0x52, /* 000002F0 "y.[.%TMR" */
- 0x5F,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41, /* 000002F8 "_._HID.A" */
- 0xD0,0x01,0x00,0x08,0x5F,0x43,0x52,0x53, /* 00000300 "...._CRS" */
- 0x11,0x10,0x0A,0x0D,0x47,0x01,0x40,0x00, /* 00000308 "....G.@." */
- 0x40,0x00,0x00,0x04,0x22,0x01,0x00,0x79, /* 00000310 "@..."..y" */
- 0x00,0x5B,0x82,0x25,0x52,0x54,0x43,0x5F, /* 00000318 ".[.%RTC_" */
- 0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0, /* 00000320 "._HID.A." */
- 0x0B,0x00,0x08,0x5F,0x43,0x52,0x53,0x11, /* 00000328 "..._CRS." */
- 0x10,0x0A,0x0D,0x47,0x01,0x70,0x00,0x70, /* 00000330 "...G.p.p" */
- 0x00,0x00,0x02,0x22,0x00,0x01,0x79,0x00, /* 00000338 "..."..y." */
- 0x5B,0x82,0x22,0x53,0x50,0x4B,0x52,0x08, /* 00000340 "[."SPKR." */
- 0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x08, /* 00000348 "_HID.A.." */
- 0x00,0x08,0x5F,0x43,0x52,0x53,0x11,0x0D, /* 00000350 ".._CRS.." */
- 0x0A,0x0A,0x47,0x01,0x61,0x00,0x61,0x00, /* 00000358 "..G.a.a." */
- 0x00,0x01,0x79,0x00,0x5B,0x82,0x31,0x50, /* 00000360 "..y.[.1P" */
- 0x53,0x32,0x4D,0x08,0x5F,0x48,0x49,0x44, /* 00000368 "S2M._HID" */
- 0x0C,0x41,0xD0,0x0F,0x13,0x08,0x5F,0x43, /* 00000370 ".A...._C" */
- 0x49,0x44,0x0C,0x41,0xD0,0x0F,0x13,0x14, /* 00000378 "ID.A...." */
- 0x09,0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A, /* 00000380 "._STA..." */
- 0x0F,0x08,0x5F,0x43,0x52,0x53,0x11,0x08, /* 00000388 ".._CRS.." */
- 0x0A,0x05,0x22,0x00,0x10,0x79,0x00,0x5B, /* 00000390 ".."..y.[" */
- 0x82,0x42,0x04,0x50,0x53,0x32,0x4B,0x08, /* 00000398 ".B.PS2K." */
- 0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x03, /* 000003A0 "_HID.A.." */
- 0x03,0x08,0x5F,0x43,0x49,0x44,0x0C,0x41, /* 000003A8 ".._CID.A" */
- 0xD0,0x03,0x0B,0x14,0x09,0x5F,0x53,0x54, /* 000003B0 "....._ST" */
- 0x41,0x00,0xA4,0x0A,0x0F,0x08,0x5F,0x43, /* 000003B8 "A....._C" */
- 0x52,0x53,0x11,0x18,0x0A,0x15,0x47,0x01, /* 000003C0 "RS....G." */
- 0x60,0x00,0x60,0x00,0x00,0x01,0x47,0x01, /* 000003C8 "`.`...G." */
- 0x64,0x00,0x64,0x00,0x00,0x01,0x22,0x02, /* 000003D0 "d.d..."." */
- 0x00,0x79,0x00,0x5B,0x82,0x3A,0x46,0x44, /* 000003D8 ".y.[.:FD" */
- 0x43,0x30,0x08,0x5F,0x48,0x49,0x44,0x0C, /* 000003E0 "C0._HID." */
- 0x41,0xD0,0x07,0x00,0x14,0x09,0x5F,0x53, /* 000003E8 "A....._S" */
- 0x54,0x41,0x00,0xA4,0x0A,0x0F,0x08,0x5F, /* 000003F0 "TA....._" */
- 0x43,0x52,0x53,0x11,0x1B,0x0A,0x18,0x47, /* 000003F8 "CRS....G" */
- 0x01,0xF0,0x03,0xF0,0x03,0x01,0x06,0x47, /* 00000400 ".......G" */
- 0x01,0xF7,0x03,0xF7,0x03,0x01,0x01,0x22, /* 00000408 "......."" */
- 0x40,0x00,0x2A,0x04,0x00,0x79,0x00,0x5B, /* 00000410 "@.*..y.[" */
- 0x82,0x36,0x55,0x41,0x52,0x31,0x08,0x5F, /* 00000418 ".6UAR1._" */
- 0x48,0x49,0x44,0x0C,0x41,0xD0,0x05,0x01, /* 00000420 "HID.A..." */
- 0x08,0x5F,0x55,0x49,0x44,0x0A,0x01,0x14, /* 00000428 "._UID..." */
- 0x09,0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A, /* 00000430 "._STA..." */
- 0x0F,0x08,0x5F,0x43,0x52,0x53,0x11,0x10, /* 00000438 ".._CRS.." */
- 0x0A,0x0D,0x47,0x01,0xF8,0x03,0xF8,0x03, /* 00000440 "..G....." */
- 0x01,0x08,0x22,0x10,0x00,0x79,0x00,0x5B, /* 00000448 ".."..y.[" */
- 0x82,0x36,0x55,0x41,0x52,0x32,0x08,0x5F, /* 00000450 ".6UAR2._" */
- 0x48,0x49,0x44,0x0C,0x41,0xD0,0x05,0x01, /* 00000458 "HID.A..." */
- 0x08,0x5F,0x55,0x49,0x44,0x0A,0x02,0x14, /* 00000460 "._UID..." */
- 0x09,0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A, /* 00000468 "._STA..." */
- 0x0F,0x08,0x5F,0x43,0x52,0x53,0x11,0x10, /* 00000470 ".._CRS.." */
- 0x0A,0x0D,0x47,0x01,0xF8,0x02,0xF8,0x02, /* 00000478 "..G....." */
- 0x01,0x08,0x22,0x08,0x00,0x79,0x00,
+ 0x24,0x06,0x05,0x20,0x08,0x50,0x4D,0x42, /* 00000020 "$.. .PMB" */
+ 0x53,0x0B,0x00,0x0C,0x08,0x50,0x4D,0x4C, /* 00000028 "S....PML" */
+ 0x4E,0x0A,0x08,0x08,0x49,0x4F,0x42,0x31, /* 00000030 "N...IOB1" */
+ 0x00,0x08,0x49,0x4F,0x4C,0x31,0x00,0x08, /* 00000038 "..IOL1.." */
+ 0x41,0x50,0x43,0x42,0x0C,0x00,0x00,0xC0, /* 00000040 "APCB...." */
+ 0xFE,0x08,0x41,0x50,0x43,0x4C,0x0C,0x00, /* 00000048 "..APCL.." */
+ 0x00,0x01,0x00,0x08,0x50,0x55,0x49,0x44, /* 00000050 "....PUID" */
+ 0x00,0x10,0x39,0x5F,0x50,0x52,0x5F,0x5B, /* 00000058 "..9_PR_[" */
+ 0x83,0x0B,0x43,0x50,0x55,0x30,0x00,0x00, /* 00000060 "..CPU0.." */
+ 0x00,0x00,0x00,0x00,0x5B,0x83,0x0B,0x43, /* 00000068 "....[..C" */
+ 0x50,0x55,0x31,0x01,0x00,0x00,0x00,0x00, /* 00000070 "PU1....." */
+ 0x00,0x5B,0x83,0x0B,0x43,0x50,0x55,0x32, /* 00000078 ".[..CPU2" */
+ 0x02,0x00,0x00,0x00,0x00,0x00,0x5B,0x83, /* 00000080 "......[." */
+ 0x0B,0x43,0x50,0x55,0x33,0x03,0x00,0x00, /* 00000088 ".CPU3..." */
+ 0x00,0x00,0x00,0x08,0x5F,0x53,0x35,0x5F, /* 00000090 "...._S5_" */
+ 0x12,0x08,0x04,0x0A,0x07,0x0A,0x07,0x00, /* 00000098 "........" */
+ 0x00,0x10,0x4A,0x3D,0x5F,0x53,0x42,0x5F, /* 000000A0 "..J=_SB_" */
+ 0x5B,0x82,0x42,0x3D,0x50,0x43,0x49,0x30, /* 000000A8 "[.B=PCI0" */
+ 0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0, /* 000000B0 "._HID.A." */
+ 0x0A,0x03,0x08,0x5F,0x55,0x49,0x44,0x00, /* 000000B8 "..._UID." */
+ 0x08,0x5F,0x41,0x44,0x52,0x00,0x08,0x5F, /* 000000C0 "._ADR.._" */
+ 0x42,0x42,0x4E,0x00,0x14,0x4A,0x06,0x5F, /* 000000C8 "BBN..J._" */
+ 0x43,0x52,0x53,0x00,0x08,0x50,0x52,0x54, /* 000000D0 "CRS..PRT" */
+ 0x30,0x11,0x48,0x05,0x0A,0x54,0x88,0x0D, /* 000000D8 "0.H..T.." */
+ 0x00,0x02,0x0F,0x00,0x00,0x00,0x00,0x00, /* 000000E0 "........" */
+ 0xFF,0x00,0x00,0x00,0x00,0x01,0x47,0x01, /* 000000E8 "......G." */
+ 0xF8,0x0C,0xF8,0x0C,0x01,0x08,0x88,0x0D, /* 000000F0 "........" */
+ 0x00,0x01,0x0C,0x03,0x00,0x00,0x00,0x00, /* 000000F8 "........" */
+ 0xF7,0x0C,0x00,0x00,0xF8,0x0C,0x88,0x0D, /* 00000100 "........" */
+ 0x00,0x01,0x0C,0x03,0x00,0x00,0x00,0x0D, /* 00000108 "........" */
+ 0xFF,0x0F,0x00,0x00,0x00,0x03,0x87,0x17, /* 00000110 "........" */
+ 0x00,0x00,0x0C,0x02,0x00,0x00,0x00,0x00, /* 00000118 "........" */
+ 0x00,0x00,0x0A,0x00,0xFF,0xFF,0x0F,0x00, /* 00000120 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00, /* 00000128 "........" */
+ 0x79,0x00,0xA4,0x50,0x52,0x54,0x30,0x08, /* 00000130 "y..PRT0." */
+ 0x41,0x49,0x52,0x30,0x12,0x4F,0x04,0x06, /* 00000138 "AIR0.O.." */
+ 0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x1F,0x00, /* 00000140 "........" */
+ 0x0A,0x02,0x00,0x0A,0x17,0x12,0x0C,0x04, /* 00000148 "........" */
+ 0x0C,0xFF,0xFF,0x1F,0x00,0x0A,0x03,0x00, /* 00000150 "........" */
+ 0x0A,0x13,0x12,0x0B,0x04,0x0C,0xFF,0xFF, /* 00000158 "........" */
+ 0x1D,0x00,0x01,0x00,0x0A,0x13,0x12,0x0B, /* 00000160 "........" */
+ 0x04,0x0C,0xFF,0xFF,0x1D,0x00,0x00,0x00, /* 00000168 "........" */
+ 0x0A,0x10,0x12,0x0C,0x04,0x0C,0xFF,0xFF, /* 00000170 "........" */
+ 0x1D,0x00,0x0A,0x02,0x00,0x0A,0x12,0x12, /* 00000178 "........" */
+ 0x0C,0x04,0x0C,0xFF,0xFF,0x1D,0x00,0x0A, /* 00000180 "........" */
+ 0x03,0x00,0x0A,0x17,0x14,0x0B,0x5F,0x50, /* 00000188 "......_P" */
+ 0x52,0x54,0x00,0xA4,0x41,0x49,0x52,0x30, /* 00000190 "RT..AIR0" */
+ 0x5B,0x82,0x42,0x2E,0x49,0x53,0x41,0x5F, /* 00000198 "[.B.ISA_" */
+ 0x08,0x5F,0x41,0x44,0x52,0x0C,0x00,0x00, /* 000001A0 "._ADR..." */
+ 0x01,0x00,0x5B,0x82,0x46,0x0B,0x53,0x59, /* 000001A8 "..[.F.SY" */
+ 0x53,0x52,0x08,0x5F,0x48,0x49,0x44,0x0C, /* 000001B0 "SR._HID." */
+ 0x41,0xD0,0x0C,0x02,0x08,0x5F,0x55,0x49, /* 000001B8 "A...._UI" */
+ 0x44,0x01,0x08,0x43,0x52,0x53,0x5F,0x11, /* 000001C0 "D..CRS_." */
+ 0x4E,0x08,0x0A,0x8A,0x47,0x01,0x10,0x00, /* 000001C8 "N...G..." */
+ 0x10,0x00,0x00,0x10,0x47,0x01,0x22,0x00, /* 000001D0 "....G."." */
+ 0x22,0x00,0x00,0x0C,0x47,0x01,0x30,0x00, /* 000001D8 ""...G.0." */
+ 0x30,0x00,0x00,0x10,0x47,0x01,0x44,0x00, /* 000001E0 "0...G.D." */
+ 0x44,0x00,0x00,0x1C,0x47,0x01,0x62,0x00, /* 000001E8 "D...G.b." */
+ 0x62,0x00,0x00,0x02,0x47,0x01,0x65,0x00, /* 000001F0 "b...G.e." */
+ 0x65,0x00,0x00,0x0B,0x47,0x01,0x72,0x00, /* 000001F8 "e...G.r." */
+ 0x72,0x00,0x00,0x0E,0x47,0x01,0x80,0x00, /* 00000200 "r...G..." */
+ 0x80,0x00,0x00,0x01,0x47,0x01,0x84,0x00, /* 00000208 "....G..." */
+ 0x84,0x00,0x00,0x03,0x47,0x01,0x88,0x00, /* 00000210 "....G..." */
+ 0x88,0x00,0x00,0x01,0x47,0x01,0x8C,0x00, /* 00000218 "....G..." */
+ 0x8C,0x00,0x00,0x03,0x47,0x01,0x90,0x00, /* 00000220 "....G..." */
+ 0x90,0x00,0x00,0x10,0x47,0x01,0xA2,0x00, /* 00000228 "....G..." */
+ 0xA2,0x00,0x00,0x1C,0x47,0x01,0xE0,0x00, /* 00000230 "....G..." */
+ 0xE0,0x00,0x00,0x10,0x47,0x01,0xA0,0x08, /* 00000238 "....G..." */
+ 0xA0,0x08,0x00,0x04,0x47,0x01,0xC0,0x0C, /* 00000240 "....G..." */
+ 0xC0,0x0C,0x00,0x10,0x47,0x01,0xD0,0x04, /* 00000248 "....G..." */
+ 0xD0,0x04,0x00,0x02,0x79,0x00,0x14,0x0B, /* 00000250 "....y..." */
+ 0x5F,0x43,0x52,0x53,0x00,0xA4,0x43,0x52, /* 00000258 "_CRS..CR" */
+ 0x53,0x5F,0x5B,0x82,0x2B,0x50,0x49,0x43, /* 00000260 "S_[.+PIC" */
+ 0x5F,0x08,0x5F,0x48,0x49,0x44,0x0B,0x41, /* 00000268 "_._HID.A" */
+ 0xD0,0x08,0x5F,0x43,0x52,0x53,0x11,0x18, /* 00000270 ".._CRS.." */
+ 0x0A,0x15,0x47,0x01,0x20,0x00,0x20,0x00, /* 00000278 "..G. . ." */
+ 0x01,0x02,0x47,0x01,0xA0,0x00,0xA0,0x00, /* 00000280 "..G....." */
+ 0x01,0x02,0x22,0x04,0x00,0x79,0x00,0x5B, /* 00000288 ".."..y.[" */
+ 0x82,0x47,0x05,0x44,0x4D,0x41,0x30,0x08, /* 00000290 ".G.DMA0." */
+ 0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x02, /* 00000298 "_HID.A.." */
+ 0x00,0x08,0x5F,0x43,0x52,0x53,0x11,0x41, /* 000002A0 ".._CRS.A" */
+ 0x04,0x0A,0x3D,0x2A,0x10,0x04,0x47,0x01, /* 000002A8 "..=*..G." */
+ 0x00,0x00,0x00,0x00,0x00,0x10,0x47,0x01, /* 000002B0 "......G." */
+ 0x81,0x00,0x81,0x00,0x00,0x03,0x47,0x01, /* 000002B8 "......G." */
+ 0x87,0x00,0x87,0x00,0x00,0x01,0x47,0x01, /* 000002C0 "......G." */
+ 0x89,0x00,0x89,0x00,0x00,0x03,0x47,0x01, /* 000002C8 "......G." */
+ 0x8F,0x00,0x8F,0x00,0x00,0x01,0x47,0x01, /* 000002D0 "......G." */
+ 0xC0,0x00,0xC0,0x00,0x00,0x20,0x47,0x01, /* 000002D8 "..... G." */
+ 0x80,0x04,0x80,0x04,0x00,0x10,0x79,0x00, /* 000002E0 "......y." */
+ 0x5B,0x82,0x25,0x54,0x4D,0x52,0x5F,0x08, /* 000002E8 "[.%TMR_." */
+ 0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x01, /* 000002F0 "_HID.A.." */
+ 0x00,0x08,0x5F,0x43,0x52,0x53,0x11,0x10, /* 000002F8 ".._CRS.." */
+ 0x0A,0x0D,0x47,0x01,0x40,0x00,0x40,0x00, /* 00000300 "..G.@.@." */
+ 0x00,0x04,0x22,0x01,0x00,0x79,0x00,0x5B, /* 00000308 ".."..y.[" */
+ 0x82,0x25,0x52,0x54,0x43,0x5F,0x08,0x5F, /* 00000310 ".%RTC_._" */
+ 0x48,0x49,0x44,0x0C,0x41,0xD0,0x0B,0x00, /* 00000318 "HID.A..." */
+ 0x08,0x5F,0x43,0x52,0x53,0x11,0x10,0x0A, /* 00000320 "._CRS..." */
+ 0x0D,0x47,0x01,0x70,0x00,0x70,0x00,0x00, /* 00000328 ".G.p.p.." */
+ 0x02,0x22,0x00,0x01,0x79,0x00,0x5B,0x82, /* 00000330 "."..y.[." */
+ 0x22,0x53,0x50,0x4B,0x52,0x08,0x5F,0x48, /* 00000338 ""SPKR._H" */
+ 0x49,0x44,0x0C,0x41,0xD0,0x08,0x00,0x08, /* 00000340 "ID.A...." */
+ 0x5F,0x43,0x52,0x53,0x11,0x0D,0x0A,0x0A, /* 00000348 "_CRS...." */
+ 0x47,0x01,0x61,0x00,0x61,0x00,0x00,0x01, /* 00000350 "G.a.a..." */
+ 0x79,0x00,0x5B,0x82,0x31,0x50,0x53,0x32, /* 00000358 "y.[.1PS2" */
+ 0x4D,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41, /* 00000360 "M._HID.A" */
+ 0xD0,0x0F,0x13,0x08,0x5F,0x43,0x49,0x44, /* 00000368 "...._CID" */
+ 0x0C,0x41,0xD0,0x0F,0x13,0x14,0x09,0x5F, /* 00000370 ".A....._" */
+ 0x53,0x54,0x41,0x00,0xA4,0x0A,0x0F,0x08, /* 00000378 "STA....." */
+ 0x5F,0x43,0x52,0x53,0x11,0x08,0x0A,0x05, /* 00000380 "_CRS...." */
+ 0x22,0x00,0x10,0x79,0x00,0x5B,0x82,0x42, /* 00000388 ""..y.[.B" */
+ 0x04,0x50,0x53,0x32,0x4B,0x08,0x5F,0x48, /* 00000390 ".PS2K._H" */
+ 0x49,0x44,0x0C,0x41,0xD0,0x03,0x03,0x08, /* 00000398 "ID.A...." */
+ 0x5F,0x43,0x49,0x44,0x0C,0x41,0xD0,0x03, /* 000003A0 "_CID.A.." */
+ 0x0B,0x14,0x09,0x5F,0x53,0x54,0x41,0x00, /* 000003A8 "..._STA." */
+ 0xA4,0x0A,0x0F,0x08,0x5F,0x43,0x52,0x53, /* 000003B0 "...._CRS" */
+ 0x11,0x18,0x0A,0x15,0x47,0x01,0x60,0x00, /* 000003B8 "....G.`." */
+ 0x60,0x00,0x00,0x01,0x47,0x01,0x64,0x00, /* 000003C0 "`...G.d." */
+ 0x64,0x00,0x00,0x01,0x22,0x02,0x00,0x79, /* 000003C8 "d..."..y" */
+ 0x00,0x5B,0x82,0x3A,0x46,0x44,0x43,0x30, /* 000003D0 ".[.:FDC0" */
+ 0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0, /* 000003D8 "._HID.A." */
+ 0x07,0x00,0x14,0x09,0x5F,0x53,0x54,0x41, /* 000003E0 "...._STA" */
+ 0x00,0xA4,0x0A,0x0F,0x08,0x5F,0x43,0x52, /* 000003E8 "....._CR" */
+ 0x53,0x11,0x1B,0x0A,0x18,0x47,0x01,0xF0, /* 000003F0 "S....G.." */
+ 0x03,0xF0,0x03,0x01,0x06,0x47,0x01,0xF7, /* 000003F8 ".....G.." */
+ 0x03,0xF7,0x03,0x01,0x01,0x22,0x40,0x00, /* 00000400 "....."@." */
+ 0x2A,0x04,0x00,0x79,0x00,0x5B,0x82,0x35, /* 00000408 "*..y.[.5" */
+ 0x55,0x41,0x52,0x31,0x08,0x5F,0x48,0x49, /* 00000410 "UAR1._HI" */
+ 0x44,0x0C,0x41,0xD0,0x05,0x01,0x08,0x5F, /* 00000418 "D.A...._" */
+ 0x55,0x49,0x44,0x01,0x14,0x09,0x5F,0x53, /* 00000420 "UID..._S" */
+ 0x54,0x41,0x00,0xA4,0x0A,0x0F,0x08,0x5F, /* 00000428 "TA....._" */
+ 0x43,0x52,0x53,0x11,0x10,0x0A,0x0D,0x47, /* 00000430 "CRS....G" */
+ 0x01,0xF8,0x03,0xF8,0x03,0x01,0x08,0x22, /* 00000438 "......."" */
+ 0x10,0x00,0x79,0x00,0x5B,0x82,0x36,0x55, /* 00000440 "..y.[.6U" */
+ 0x41,0x52,0x32,0x08,0x5F,0x48,0x49,0x44, /* 00000448 "AR2._HID" */
+ 0x0C,0x41,0xD0,0x05,0x01,0x08,0x5F,0x55, /* 00000450 ".A...._U" */
+ 0x49,0x44,0x0A,0x02,0x14,0x09,0x5F,0x53, /* 00000458 "ID...._S" */
+ 0x54,0x41,0x00,0xA4,0x0A,0x0F,0x08,0x5F, /* 00000460 "TA....._" */
+ 0x43,0x52,0x53,0x11,0x10,0x0A,0x0D,0x47, /* 00000468 "CRS....G" */
+ 0x01,0xF8,0x02,0xF8,0x02,0x01,0x08,0x22, /* 00000470 "......."" */
+ 0x08,0x00,0x79,0x00,
};
int DsdtLen=sizeof(AmlCode);
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/firmware/acpi/acpi_fadt.h
--- a/tools/firmware/acpi/acpi_fadt.h Mon May 22 08:53:26 2006 -0600
+++ b/tools/firmware/acpi/acpi_fadt.h Mon May 22 14:13:38 2006 -0600
@@ -59,7 +59,7 @@
#define ACPI_PM1A_EVT_BLK_ADDRESS_SPACE_ID ACPI_SYSTEM_IO
#define ACPI_PM1A_EVT_BLK_BIT_WIDTH 0x00
#define ACPI_PM1A_EVT_BLK_BIT_OFFSET 0x00
-#define ACPI_PM1A_EVT_BLK_ADDRESS 0x0000000000000000
+#define ACPI_PM1A_EVT_BLK_ADDRESS 0x0000000000008000
//
// PM1B Event Register Block Generic Address Information
@@ -73,7 +73,7 @@
// PM1A Control Register Block Generic Address Information
//
#define ACPI_PM1A_CNT_BLK_ADDRESS_SPACE_ID ACPI_SYSTEM_IO
-#define ACPI_PM1A_CNT_BLK_BIT_WIDTH 0x10
+#define ACPI_PM1A_CNT_BLK_BIT_WIDTH 0x08
#define ACPI_PM1A_CNT_BLK_BIT_OFFSET 0x00
#define ACPI_PM1A_CNT_BLK_ADDRESS (ACPI_PM1A_EVT_BLK_ADDRESS + 0x04)
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/ioemu/hw/cirrus_vga.c
--- a/tools/ioemu/hw/cirrus_vga.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/ioemu/hw/cirrus_vga.c Mon May 22 14:13:38 2006 -0600
@@ -28,6 +28,9 @@
*/
#include "vl.h"
#include "vga_int.h"
+#ifndef _WIN32
+#include <sys/mman.h>
+#endif
/*
* TODO:
@@ -269,7 +272,8 @@ typedef struct CirrusVGAState {
int last_hw_cursor_y_end;
int real_vram_size; /* XXX: suppress that */
CPUWriteMemoryFunc **cirrus_linear_write;
- int set_mapping;
+ unsigned long map_addr;
+ unsigned long map_end;
} CirrusVGAState;
typedef struct PCICirrusVGAState {
@@ -1187,6 +1191,17 @@ cirrus_hook_write_sr(CirrusVGAState * s,
s->hw_cursor_y = (reg_value << 3) | (reg_index >> 5);
break;
case 0x07: // Extended Sequencer Mode
+ /* Win2K seems to assume that the VRAM is set to 0xff
+ * whenever VGA/SVGA mode changes
+ */
+ if ((s->sr[0x07] ^ reg_value) & CIRRUS_SR7_BPP_SVGA)
+ memset(s->vram_ptr, 0xff, s->real_vram_size);
+ s->sr[0x07] = reg_value;
+#ifdef DEBUG_CIRRUS
+ printf("cirrus: handled outport sr_index %02x, sr_value %02x\n",
+ reg_index, reg_value);
+#endif
+ break;
case 0x08: // EEPROM Control
case 0x09: // Scratch Register 0
case 0x0a: // Scratch Register 1
@@ -2444,14 +2459,97 @@ static CPUWriteMemoryFunc *cirrus_linear
cirrus_linear_bitblt_writel,
};
+extern FILE *logfile;
+#if defined(__i386__) || defined (__x86_64__)
+static void * set_vram_mapping(unsigned long begin, unsigned long end)
+{
+ unsigned long * extent_start = NULL;
+ unsigned long nr_extents;
+ void *vram_pointer = NULL;
+ int i;
+
+ /* align begin and end address */
+ begin = begin & TARGET_PAGE_MASK;
+ end = begin + VGA_RAM_SIZE;
+ end = (end + TARGET_PAGE_SIZE -1 ) & TARGET_PAGE_MASK;
+ nr_extents = (end - begin) >> TARGET_PAGE_BITS;
+
+ extent_start = malloc(sizeof(unsigned long) * nr_extents );
+ if (extent_start == NULL)
+ {
+ fprintf(stderr, "Failed malloc on set_vram_mapping\n");
+ return NULL;
+ }
+
+ memset(extent_start, 0, sizeof(unsigned long) * nr_extents);
+
+ for (i = 0; i < nr_extents; i++)
+ {
+ extent_start[i] = (begin + i * TARGET_PAGE_SIZE) >> TARGET_PAGE_BITS;
+ }
+
+ set_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start);
+
+ if ( (vram_pointer = xc_map_foreign_batch(xc_handle, domid,
+ PROT_READ|PROT_WRITE,
+ extent_start,
+ nr_extents)) == NULL)
+ {
+ fprintf(logfile,
+ "xc_map_foreign_batch vgaram returned error %d\n", errno);
+ return NULL;
+ }
+
+ memset(vram_pointer, 0, nr_extents * TARGET_PAGE_SIZE);
+
+ free(extent_start);
+
+ return vram_pointer;
+}
+
+static int unset_vram_mapping(unsigned long begin, unsigned long end)
+{
+ unsigned long * extent_start = NULL;
+ unsigned long nr_extents;
+ int i;
+
+ /* align begin and end address */
+
+ end = begin + VGA_RAM_SIZE;
+ begin = begin & TARGET_PAGE_MASK;
+ end = (end + TARGET_PAGE_SIZE -1 ) & TARGET_PAGE_MASK;
+ nr_extents = (end - begin) >> TARGET_PAGE_BITS;
+
+ extent_start = malloc(sizeof(unsigned long) * nr_extents );
+
+ if (extent_start == NULL)
+ {
+ fprintf(stderr, "Failed malloc on set_mm_mapping\n");
+ return -1;
+ }
+
+ memset(extent_start, 0, sizeof(unsigned long) * nr_extents);
+
+ for (i = 0; i < nr_extents; i++)
+ extent_start[i] = (begin + (i * TARGET_PAGE_SIZE)) >> TARGET_PAGE_BITS;
+
+ unset_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start);
+
+ free(extent_start);
+
+ return 0;
+}
+
+#elif defined(__ia64__)
+static void * set_vram_mapping(unsigned long addr, unsigned long end) {}
+static int unset_vram_mapping(unsigned long addr, unsigned long end) {}
+#endif
+extern int vga_accelerate;
+
/* Compute the memory access functions */
static void cirrus_update_memory_access(CirrusVGAState *s)
{
unsigned mode;
- extern void * set_vram_mapping(unsigned long addr, unsigned long end);
-
- extern int unset_vram_mapping(unsigned long addr, unsigned long end);
- extern int vga_accelerate;
if ((s->sr[0x17] & 0x44) == 0x44) {
goto generic_io;
@@ -2466,18 +2564,21 @@ static void cirrus_update_memory_access(
mode = s->gr[0x05] & 0x7;
if (mode < 4 || mode > 5 || ((s->gr[0x0B] & 0x4) == 0)) {
- if (vga_accelerate && s->cirrus_lfb_addr && s->cirrus_lfb_end) {
- if (!s->set_mapping) {
- void * vram_pointer;
- s->set_mapping = 1;
- vram_pointer = set_vram_mapping(s->cirrus_lfb_addr
,s->cirrus_lfb_end);
- if (!vram_pointer){
+ if ( vga_accelerate && s->cirrus_lfb_addr && s->cirrus_lfb_end ) {
+ if (!s->map_addr) {
+ void *vram_pointer, *old_vram;
+
+ vram_pointer =
+ set_vram_mapping(s->cirrus_lfb_addr ,s->cirrus_lfb_end);
+ if (!vram_pointer) {
fprintf(stderr, "NULL vram_pointer\n");
- } else
- {
- vga_update_vram((VGAState *)s, vram_pointer,
+ } else {
+ old_vram = vga_update_vram((VGAState *)s, vram_pointer,
VGA_RAM_SIZE);
+ qemu_free(old_vram);
}
+ s->map_addr = s->cirrus_lfb_addr;
+ s->map_end = s->cirrus_lfb_end;
}
}
s->cirrus_linear_write[0] = cirrus_linear_mem_writeb;
@@ -2486,13 +2587,19 @@ static void cirrus_update_memory_access(
} else {
generic_io:
if (vga_accelerate && s->cirrus_lfb_addr && s->cirrus_lfb_end) {
- if(s->set_mapping) {
+ if(s->map_addr) {
int error;
- s->set_mapping = 0;
+ void *old_vram = NULL;
+
error = unset_vram_mapping(s->cirrus_lfb_addr,
s->cirrus_lfb_end);
if (!error)
- vga_update_vram((VGAState *)s, NULL, VGA_RAM_SIZE);
+ old_vram =
+ vga_update_vram((VGAState *)s, NULL, VGA_RAM_SIZE);
+
+ if (old_vram)
+ munmap(old_vram, s->map_addr - s->map_end);
+ s->map_addr = s->map_end = 0;
}
}
@@ -3021,10 +3128,6 @@ static void cirrus_init_common(CirrusVGA
}
s->cr[0x27] = device_id;
- /* Win2K seems to assume that the pattern buffer is at 0xff
- initially ! */
- memset(s->vram_ptr, 0xff, s->real_vram_size);
-
s->cirrus_hidden_dac_lockindex = 5;
s->cirrus_hidden_dac_data = 0;
@@ -3091,6 +3194,12 @@ static void cirrus_pci_lfb_map(PCIDevice
s->cirrus_linear_io_addr);
s->cirrus_lfb_addr = addr;
s->cirrus_lfb_end = addr + VGA_RAM_SIZE;
+
+ if ( vga_accelerate && s->map_addr &&
+ (s->cirrus_lfb_addr != s->map_addr) &&
+ (s->cirrus_lfb_end != s->map_end))
+ fprintf(logfile, "cirrus vga map change while on lfb mode\n");
+
cpu_register_physical_memory(addr + 0x1000000, 0x400000,
s->cirrus_linear_bitblt_io_addr);
}
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/ioemu/hw/mc146818rtc.c
--- a/tools/ioemu/hw/mc146818rtc.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/ioemu/hw/mc146818rtc.c Mon May 22 14:13:38 2006 -0600
@@ -178,10 +178,27 @@ static inline int from_bcd(RTCState *s,
}
}
+static void send_timeoffset_msg(time_t delta)
+{
+
+/* This routine is used to inform another entity that the
+ base time offset has changed. For instance, if you
+ were using xenstore, you might want to write to the store
+ at this point. Or, you might use some other method.
+ Whatever you might choose, here's a hook point to implement it.
+
+ One item of note is that this delta is in addition to
+ any existing offset you might be already using. */
+
+ return;
+}
+
static void rtc_set_time(RTCState *s)
{
struct tm *tm = &s->current_tm;
-
+ time_t before, after;
+
+ before = mktime(tm);
tm->tm_sec = from_bcd(s, s->cmos_data[RTC_SECONDS]);
tm->tm_min = from_bcd(s, s->cmos_data[RTC_MINUTES]);
tm->tm_hour = from_bcd(s, s->cmos_data[RTC_HOURS] & 0x7f);
@@ -193,6 +210,12 @@ static void rtc_set_time(RTCState *s)
tm->tm_mday = from_bcd(s, s->cmos_data[RTC_DAY_OF_MONTH]);
tm->tm_mon = from_bcd(s, s->cmos_data[RTC_MONTH]) - 1;
tm->tm_year = from_bcd(s, s->cmos_data[RTC_YEAR]) + 100;
+
+ /* Compute, and send, the additional time delta
+ We could compute the total time delta, but this is
+ sufficient, and simple. */
+ after = mktime(tm);
+ send_timeoffset_msg(after-before);
}
static void rtc_copy_date(RTCState *s)
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/ioemu/hw/pc.c
--- a/tools/ioemu/hw/pc.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/ioemu/hw/pc.c Mon May 22 14:13:38 2006 -0600
@@ -118,7 +118,7 @@ static void cmos_init_hd(int type_ofs, i
}
/* hd_table must contain 4 block drivers */
-static void cmos_init(uint64_t ram_size, int boot_device, BlockDriverState
**hd_table)
+static void cmos_init(uint64_t ram_size, int boot_device, BlockDriverState
**hd_table, time_t timeoffset)
{
RTCState *s = rtc_state;
int val;
@@ -129,6 +129,7 @@ static void cmos_init(uint64_t ram_size,
/* set the CMOS date */
time(&ti);
+ ti += timeoffset;
if (rtc_utc)
tm = gmtime(&ti);
else
@@ -373,18 +374,20 @@ static int serial_io[MAX_SERIAL_PORTS] =
static int serial_io[MAX_SERIAL_PORTS] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
static int serial_irq[MAX_SERIAL_PORTS] = { 4, 3, 4, 3 };
+extern int acpi_init(unsigned int base);
+
#define NOBIOS 1
/* PC hardware initialisation */
void pc_init(uint64_t ram_size, int vga_ram_size, int boot_device,
DisplayState *ds, const char **fd_filename, int snapshot,
const char *kernel_filename, const char *kernel_cmdline,
- const char *initrd_filename)
-{
+ const char *initrd_filename, time_t timeoffset)
+{
+ SerialState *sp;
char buf[1024];
int ret, linux_boot, initrd_size, i, nb_nics1;
PCIBus *pci_bus;
- extern void * shared_vram;
linux_boot = (kernel_filename != NULL);
@@ -511,14 +514,14 @@ void pc_init(uint64_t ram_size, int vga_
if (cirrus_vga_enabled) {
if (pci_enabled) {
pci_cirrus_vga_init(pci_bus,
- ds, shared_vram, ram_size,
+ ds, NULL, ram_size,
vga_ram_size);
} else {
- isa_cirrus_vga_init(ds, shared_vram, ram_size,
+ isa_cirrus_vga_init(ds, NULL, ram_size,
vga_ram_size);
}
} else {
- vga_initialize(pci_bus, ds, shared_vram, ram_size,
+ vga_initialize(pci_bus, ds, NULL, ram_size,
vga_ram_size);
}
@@ -533,7 +536,9 @@ void pc_init(uint64_t ram_size, int vga_
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
if (serial_hds[i]) {
- serial_init(serial_io[i], serial_irq[i], serial_hds[i]);
+ sp = serial_init(serial_io[i], serial_irq[i], serial_hds[i]);
+ if (i == SUMMA_PORT)
+ summa_init(sp, serial_hds[i]);
}
}
@@ -573,7 +578,8 @@ void pc_init(uint64_t ram_size, int vga_
floppy_controller = fdctrl_init(6, 2, 0, 0x3f0, fd_table);
- cmos_init(ram_size, boot_device, bs_table);
+ cmos_init(ram_size, boot_device, bs_table, timeoffset);
+ acpi_init(0x8000);
/* must be done after all PCI devices are instanciated */
/* XXX: should be done in the Bochs BIOS */
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/ioemu/hw/pckbd.c
--- a/tools/ioemu/hw/pckbd.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/ioemu/hw/pckbd.c Mon May 22 14:13:38 2006 -0600
@@ -156,10 +156,23 @@ typedef struct KBDState {
int mouse_dz;
uint8_t mouse_buttons;
CharDriverState *chr;
- void *cookie;
+ SerialState *serial;
} KBDState;
KBDState kbd_state;
+
+#define MODE_STREAM_SWITCH 0
+#define MODE_STREAM 1
+#define MODE_REMOTE 2
+#define MODE_POINT 3
+
+#define ORIGIN_LOWER_LEFT 0
+#define ORIGIN_UPPER_LEFT 1
+
+struct SummaState {
+ int report_mode;
+ int origin;
+} SummaState;
int summa_ok; /* Allow Summagraphics emulation if true */
@@ -420,15 +433,19 @@ static int kbd_mouse_send_packet(KBDStat
switch(s->mouse_type) {
case TABLET: /* Summagraphics pen tablet */
- dx1 = s->mouse_x;
- dy1 = s->mouse_y;
- dx1 = ((dx1 * SUMMA_MAXX) / mouse_maxx) + SUMMA_BORDER;
- dy1 = ((dy1 * SUMMA_MAXY) / mouse_maxy) + SUMMA_BORDER;
- ser_queue(s->cookie, 0x80 | (s->mouse_buttons & 7));
- ser_queue(s->cookie, dx1 & 0x7f);
- ser_queue(s->cookie, dx1 >> 7);
- ser_queue(s->cookie, dy1 & 0x7f);
- ser_queue(s->cookie, dy1 >> 7);
+ if (SummaState.report_mode == MODE_STREAM) {
+ dx1 = s->mouse_x;
+ dy1 = s->mouse_y;
+ if (SummaState.origin == ORIGIN_LOWER_LEFT)
+ dy1 = mouse_maxy - dy1;
+ dx1 = ((dx1 * SUMMA_MAXX) / mouse_maxx) + SUMMA_BORDER;
+ dy1 = ((dy1 * SUMMA_MAXY) / mouse_maxy) + SUMMA_BORDER;
+ ser_queue(s->serial, 0x80 | (s->mouse_buttons & 7));
+ ser_queue(s->serial, dx1 & 0x7f);
+ ser_queue(s->serial, dx1 >> 7);
+ ser_queue(s->serial, dy1 & 0x7f);
+ ser_queue(s->serial, dy1 >> 7);
+ }
s->mouse_dx = 0;
s->mouse_dy = 0;
s->mouse_dz = 0;
@@ -509,43 +526,101 @@ static void pc_kbd_mouse_event(void *opa
}
}
-static void summa(KBDState *s, int val)
-{
- static int summa = 0;
-
- if (s->mouse_type == TABLET) {
+static void summa(KBDState *s, uint8_t val)
+{
+ static int zflg = 0;
+
+ if (zflg) {
+ zflg = 0;
switch (val) {
- case '?': /* read firmware ID */
- ser_queue(s->cookie, '0');
+ case 'b': /* binary report mode */
break;
- case 'a': /* read config */
- /*
- * Config looks like a movement packet but, because of scaling
- * issues we can't use `kbd_send_packet' to do this.
- */
- ser_queue(s->cookie, 0);
- ser_queue(s->cookie, (SUMMA_MAXX & 0x7f));
- ser_queue(s->cookie, (SUMMA_MAXX >> 7));
- ser_queue(s->cookie, (SUMMA_MAXY & 0x7f));
- ser_queue(s->cookie, (SUMMA_MAXY >> 7));
- break;
-
- default: /* ignore all others */
+ case 't': /* stylus type - we do 4 button cursor */
+ ser_queue(s->serial, 'C');
+ ser_queue(s->serial, 'S');
+ ser_queue(s->serial, 'R');
+ ser_queue(s->serial, '4');
+ ser_queue(s->serial, '\r');
break;
}
return;
}
- if (val == 'B') {
- summa++;
- return;
- } else if (summa && val == 'z') {
+ zflg = 0;
+
+ switch (val) {
+
+ case 'B': /* point mode */
+ /* This is supposed to be `set to point mode' but the Linux driver
+ * is broken and incorrectly sends a reset command (somebody
+ * needs to learn that the address 0 does not necessarily contain
+ * a zero). This is the first valid command that Linux sends
+ * out so we'll treat it as a reset
+ */
+ case '\0': /* reset */
s->mouse_type = TABLET;
- return;
- }
- summa = 0;
+ s->mouse_status |= MOUSE_STATUS_ENABLED;
+ SummaState.origin = ORIGIN_LOWER_LEFT;
+ SummaState.report_mode = (val == 'B') ? MODE_POINT : MODE_STREAM_SWITCH;
+ break;
+
+ case 'z': /* start of 2 byte command */
+ zflg++;
+ break;
+
+ case 'x': /* code check */
+ /*
+ * Return checksum
+ */
+ ser_queue(s->serial, '.');
+ ser_queue(s->serial, '#');
+ ser_queue(s->serial, '1');
+ ser_queue(s->serial, '2');
+ ser_queue(s->serial, '3');
+ ser_queue(s->serial, '4');
+ break;
+
+ case '?': /* read firmware ID */
+ ser_queue(s->serial, '0');
+ break;
+
+ case 'a': /* read config */
+ /*
+ * Config looks like a movement packet but, because of scaling
+ * issues we can't use `kbd_send_packet' to do this.
+ */
+ ser_queue(s->serial, 0x94);
+ ser_queue(s->serial, (SUMMA_MAXX & 0x7f));
+ ser_queue(s->serial, (SUMMA_MAXX >> 7));
+ ser_queue(s->serial, (SUMMA_MAXY & 0x7f));
+ ser_queue(s->serial, (SUMMA_MAXY >> 7));
+ break;
+
+ case 'b': /* origin at upper left */
+ SummaState.origin = ORIGIN_UPPER_LEFT;
+ break;
+
+ case 'c': /* origin at lower left */
+ SummaState.origin = ORIGIN_LOWER_LEFT;
+ break;
+
+ case '@': /* stream mode */
+ SummaState.report_mode = MODE_STREAM;
+ break;
+
+ case 'D': /* remote request mode */
+ SummaState.report_mode = MODE_REMOTE;
+ break;
+
+ case 'P': /* trigger, e.g. send report now */
+ case 'R': /* report rate = max/2 */
+ default: /* ignore all others */
+ break;
+
+ }
+
return;
}
@@ -560,13 +635,13 @@ int summa_write(CharDriverState *chr, co
return len;
}
-void summa_init(void *cookie, CharDriverState *chr)
+void summa_init(SerialState *serial, CharDriverState *chr)
{
if (summa_ok == 0)
return;
kbd_state.chr = chr;
- kbd_state.cookie = (void *)cookie;
+ kbd_state.serial = serial;
chr->chr_write = summa_write;
chr->opaque = (void *)&kbd_state;
return;
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/ioemu/hw/serial.c
--- a/tools/ioemu/hw/serial.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/ioemu/hw/serial.c Mon May 22 14:13:38 2006 -0600
@@ -310,7 +310,6 @@ SerialState *serial_init(int base, int i
register_ioport_write(base, 8, 1, serial_ioport_write, s);
register_ioport_read(base, 8, 1, serial_ioport_read, s);
s->chr = chr;
- summa_init(s, chr);
qemu_chr_add_read_handler(chr, serial_can_receive1, serial_receive1, s);
qemu_chr_add_event_handler(chr, serial_event);
return s;
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/ioemu/hw/vga.c
--- a/tools/ioemu/hw/vga.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/ioemu/hw/vga.c Mon May 22 14:13:38 2006 -0600
@@ -1946,11 +1946,11 @@ void vga_bios_init(VGAState *s)
}
+/* when used on xen environment, the vga_ram_base is not used */
void vga_common_init(VGAState *s, DisplayState *ds, uint8_t *vga_ram_base,
unsigned long vga_ram_offset, int vga_ram_size)
{
int i, j, v, b;
- extern void* shared_vram;
for(i = 0;i < 256; i++) {
v = 0;
@@ -1979,11 +1979,7 @@ void vga_common_init(VGAState *s, Displa
/* qemu's vga mem is not detached from phys_ram_base and can cause DM abort
* when guest write vga mem, so allocate a new one */
-#if defined(__i386__) || defined(__x86_64__)
- s->vram_ptr = shared_vram;
-#else
s->vram_ptr = qemu_malloc(vga_ram_size);
-#endif
check_sse2();
s->vram_shadow = qemu_malloc(vga_ram_size+TARGET_PAGE_SIZE+1);
if (s->vram_shadow == NULL)
@@ -2090,12 +2086,14 @@ int vga_initialize(PCIBus *bus, DisplayS
return 0;
}
-int vga_update_vram(VGAState *s, void *vga_ram_base, int vga_ram_size)
-{
+void *vga_update_vram(VGAState *s, void *vga_ram_base, int vga_ram_size)
+{
+ uint8_t *old_pointer;
+
if (s->vram_size != vga_ram_size)
{
fprintf(stderr, "No support to change vga_ram_size\n");
- return -1;
+ return NULL;
}
if ( !vga_ram_base )
@@ -2104,15 +2102,16 @@ int vga_update_vram(VGAState *s, void *v
if (!vga_ram_base)
{
fprintf(stderr, "reallocate error\n");
- return -1;
+ return NULL;
}
}
/* XXX lock needed? */
memcpy(vga_ram_base, s->vram_ptr, vga_ram_size);
+ old_pointer = s->vram_ptr;
s->vram_ptr = vga_ram_base;
- return 0;
+ return old_pointer;
}
/********************************************************/
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/ioemu/hw/vga_int.h
--- a/tools/ioemu/hw/vga_int.h Mon May 22 08:53:26 2006 -0600
+++ b/tools/ioemu/hw/vga_int.h Mon May 22 14:13:38 2006 -0600
@@ -165,6 +165,6 @@ void vga_draw_cursor_line_32(uint8_t *d1
unsigned int color0, unsigned int color1,
unsigned int color_xor);
-int vga_update_vram(VGAState *s, void *vga_ram_base, int vga_ram_size);
+void *vga_update_vram(VGAState *s, void *vga_ram_base, int vga_ram_size);
extern const uint8_t sr_mask[8];
extern const uint8_t gr_mask[16];
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/ioemu/target-i386-dm/Makefile
--- a/tools/ioemu/target-i386-dm/Makefile Mon May 22 08:53:26 2006 -0600
+++ b/tools/ioemu/target-i386-dm/Makefile Mon May 22 14:13:38 2006 -0600
@@ -278,7 +278,7 @@ endif
# Hardware support
VL_OBJS+= ide.o ne2000.o pckbd.o vga.o dma.o
VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259_stub.o pc.o port-e9.o
-VL_OBJS+= cirrus_vga.o pcnet.o
+VL_OBJS+= cirrus_vga.o pcnet.o acpi.o
VL_OBJS+= $(SOUND_HW) $(AUDIODRV) mixeng.o
ifeq ($(TARGET_ARCH), ppc)
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/ioemu/vl.c
--- a/tools/ioemu/vl.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/ioemu/vl.c Mon May 22 14:13:38 2006 -0600
@@ -75,8 +75,6 @@
#endif
#endif /* CONFIG_SDL */
-#include "xenctrl.h"
-#include "xs.h"
#include "exec-all.h"
//#define DO_TB_FLUSH
@@ -149,12 +147,7 @@ TextConsole *vga_console;
TextConsole *vga_console;
CharDriverState *serial_hds[MAX_SERIAL_PORTS];
int xc_handle;
-unsigned long *vgapage_array;
-unsigned long *freepage_array;
-unsigned long free_pages;
-void *vtop_table;
-unsigned long toptab;
-unsigned long vgaram_pages;
+time_t timeoffset = 0;
/***********************************************************/
/* x86 ISA bus support */
@@ -2255,9 +2248,10 @@ void help(void)
"-s wait gdb connection to port %d\n"
"-p port ioreq port for xen\n"
"-d domain domain that we're serving\n"
- "-domain-namn domain name that we're serving\n"
+ "-domain-name domain name that we're serving\n"
"-hdachs c,h,s force hard disk 0 geometry (usually qemu can guess
it)\n"
"-L path set the directory for the BIOS and VGA BIOS\n"
+ "-timeoffset time offset (in seconds) from local time (Xen)\n"
#ifdef USE_CODE_COPY
"-no-code-copy disable code copy acceleration\n"
#endif
@@ -2355,6 +2349,7 @@ enum {
QEMU_OPTION_monitor,
QEMU_OPTION_domainname,
QEMU_OPTION_serial,
+ QEMU_OPTION_timeoffset,
QEMU_OPTION_loadvm,
QEMU_OPTION_full_screen,
QEMU_OPTION_vgaacc,
@@ -2428,6 +2423,7 @@ const QEMUOption qemu_options[] = {
{ "std-vga", 0, QEMU_OPTION_std_vga },
{ "monitor", 1, QEMU_OPTION_monitor },
{ "domain-name", 1, QEMU_OPTION_domainname },
+ { "timeoffset", HAS_ARG, QEMU_OPTION_timeoffset },
{ "serial", 1, QEMU_OPTION_serial },
{ "loadvm", HAS_ARG, QEMU_OPTION_loadvm },
{ "full-screen", 0, QEMU_OPTION_full_screen },
@@ -2456,35 +2452,8 @@ static uint8_t *signal_stack;
#include <xg_private.h>
-#if defined(__i386__) || defined (__x86_64__)
-#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_USER)
-#define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
-
-#ifdef __i386__
-#define _LEVEL_3_ 0
-#else
-#define _LEVEL_3_ 1
-#endif
-
-#if _LEVEL_3_
-#define L3_PROT (_PAGE_PRESENT)
-#define L1_PAGETABLE_ENTRIES 512
-#else
-#define L1_PAGETABLE_ENTRIES 1024
-#endif
-
-inline int
-get_vl2_table(unsigned long count, unsigned long start)
-{
-#if _LEVEL_3_
- return ((start + (count << PAGE_SHIFT)) >> L3_PAGETABLE_SHIFT) & 0x3;
-#else
- return 0;
-#endif
-}
-
/* FIXME Flush the shadow page */
-static int unset_mm_mapping(int xc_handle,
+int unset_mm_mapping(int xc_handle,
uint32_t domid,
unsigned long nr_pages,
unsigned int address_bits,
@@ -2517,13 +2486,12 @@ static int unset_mm_mapping(int xc_handl
return err;
}
-static int set_mm_mapping(int xc_handle,
+int set_mm_mapping(int xc_handle,
uint32_t domid,
unsigned long nr_pages,
unsigned int address_bits,
unsigned long *extent_start)
{
- int i;
xc_dominfo_t info;
int err = 0;
@@ -2563,91 +2531,6 @@ static int set_mm_mapping(int xc_handle,
return 0;
}
-
-
-void * set_vram_mapping(unsigned long begin, unsigned long end)
-{
- unsigned long * extent_start = NULL;
- unsigned long nr_extents;
- void *vram_pointer = NULL;
- int i;
-
- /* align begin and end address */
- begin = begin & PAGE_MASK;
- end = begin + VGA_RAM_SIZE;
- end = (end + PAGE_SIZE -1 )& PAGE_MASK;
- nr_extents = (end - begin) >> PAGE_SHIFT;
-
- extent_start = malloc(sizeof(unsigned long) * nr_extents );
- if (extent_start == NULL)
- {
- fprintf(stderr, "Failed malloc on set_vram_mapping\n");
- return NULL;
- }
-
- memset(extent_start, 0, sizeof(unsigned long) * nr_extents);
-
- for (i = 0; i < nr_extents; i++)
- {
- extent_start[i] = (begin + i * PAGE_SIZE) >> PAGE_SHIFT;
- }
-
- set_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start);
-
- if ( (vram_pointer = xc_map_foreign_batch(xc_handle, domid,
- PROT_READ|PROT_WRITE,
- extent_start,
- nr_extents)) == NULL)
- {
- fprintf(logfile,
- "xc_map_foreign_batch vgaram returned error %d\n", errno);
- return NULL;
- }
-
- memset(vram_pointer, 0, nr_extents * PAGE_SIZE);
-
- free(extent_start);
-
- return vram_pointer;
-}
-
-int unset_vram_mapping(unsigned long begin, unsigned long end)
-{
- unsigned long * extent_start = NULL;
- unsigned long nr_extents;
- int i;
-
- /* align begin and end address */
-
- end = begin + VGA_RAM_SIZE;
- begin = begin & PAGE_MASK;
- end = (end + PAGE_SIZE -1 ) & PAGE_MASK;
- nr_extents = (end - begin) >> PAGE_SHIFT;
-
- extent_start = malloc(sizeof(unsigned long) * nr_extents );
-
- if (extent_start == NULL)
- {
- fprintf(stderr, "Failed malloc on set_mm_mapping\n");
- return -1;
- }
-
- memset(extent_start, 0, sizeof(unsigned long) * nr_extents);
-
- for (i = 0; i < nr_extents; i++)
- extent_start[i] = (begin + (i * PAGE_SIZE)) >> PAGE_SHIFT;
-
- unset_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start);
-
- free(extent_start);
-
- return 0;
-}
-
-#elif defined(__ia64__)
-void set_vram_mapping(unsigned long addr, unsigned long end) {}
-void unset_vram_mapping(unsigned long addr, unsigned long end) {}
-#endif
int main(int argc, char **argv)
{
@@ -2673,10 +2556,8 @@ int main(int argc, char **argv)
int serial_device_index;
char qemu_dm_logfilename[64];
const char *loadvm = NULL;
- unsigned long nr_pages, extra_pages, ram_pages, *page_array;
- xc_dominfo_t info;
+ unsigned long nr_pages, *page_array;
extern void *shared_page;
- extern void *shared_vram;
#if !defined(CONFIG_SOFTMMU)
/* we never want that malloc() uses mmap() */
@@ -2707,7 +2588,8 @@ int main(int argc, char **argv)
pstrcpy(monitor_device, sizeof(monitor_device), "vc");
pstrcpy(serial_devices[0], sizeof(serial_devices[0]), "vc");
- for(i = 1; i < MAX_SERIAL_PORTS; i++)
+ pstrcpy(serial_devices[1], sizeof(serial_devices[1]), "null");
+ for(i = 2; i < MAX_SERIAL_PORTS; i++)
serial_devices[i][0] = '\0';
serial_device_index = 0;
@@ -3058,7 +2940,10 @@ int main(int argc, char **argv)
case QEMU_OPTION_domainname:
strncat(domain_name, optarg, sizeof(domain_name) - 20);
break;
-
+ case QEMU_OPTION_timeoffset:
+ timeoffset = strtol(optarg, NULL, 0);
+ break;
+
}
}
}
@@ -3133,28 +3018,9 @@ int main(int argc, char **argv)
/* init the memory */
phys_ram_size = ram_size + vga_ram_size + bios_size;
- ram_pages = ram_size/PAGE_SIZE;
-#if defined(__i386__) || defined(__x86_64__)
- vgaram_pages = (vga_ram_size -1) / PAGE_SIZE + 1;
- free_pages = vgaram_pages / L1_PAGETABLE_ENTRIES;
- extra_pages = vgaram_pages + free_pages;
-#else
- /* Test vga acceleration later */
- extra_pages = 0;
-#endif
+ nr_pages = ram_size/PAGE_SIZE;
xc_handle = xc_interface_open();
-
- xc_domain_getinfo(xc_handle, domid, 1, &info);
-
- nr_pages = info.nr_pages + extra_pages;
-
- if ( xc_domain_setmaxmem(xc_handle, domid,
- (nr_pages) * PAGE_SIZE/1024 ) != 0)
- {
- fprintf(logfile, "set maxmem returned error %d\n", errno);
- exit(-1);
- }
if ( (page_array = (unsigned long *)
malloc(nr_pages * sizeof(unsigned long))) == NULL)
@@ -3163,24 +3029,16 @@ int main(int argc, char **argv)
exit(-1);
}
- if (xc_domain_memory_increase_reservation(xc_handle, domid,
- extra_pages , 0, 0, NULL) != 0)
- {
- fprintf(logfile, "increase reservation returned error %d\n", errno);
- exit(-1);
- }
-
#if defined(__i386__) || defined(__x86_64__)
if ( xc_get_pfn_list(xc_handle, domid, page_array, nr_pages) != nr_pages )
{
fprintf(logfile, "xc_get_pfn_list returned error %d\n", errno);
exit(-1);
}
-
if ( (phys_ram_base = xc_map_foreign_batch(xc_handle, domid,
PROT_READ|PROT_WRITE,
page_array,
- ram_pages - 1)) == 0 )
+ nr_pages - 1)) == 0 )
{
fprintf(logfile, "xc_map_foreign_batch returned error %d\n", errno);
exit(-1);
@@ -3188,31 +3046,11 @@ int main(int argc, char **argv)
shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
PROT_READ|PROT_WRITE,
- page_array[ram_pages - 1]);
-
- vgapage_array = &page_array[nr_pages - vgaram_pages];
-
- if ( (shared_vram = xc_map_foreign_batch(xc_handle, domid,
- PROT_READ|PROT_WRITE,
- vgapage_array,
- vgaram_pages)) == 0)
- {
- fprintf(logfile,
- "xc_map_foreign_batch vgaram returned error %d\n", errno);
- exit(-1);
- }
-
- memset(shared_vram, 0, vgaram_pages * PAGE_SIZE);
- toptab = page_array[ram_pages] << PAGE_SHIFT;
-
- vtop_table = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
- PROT_READ|PROT_WRITE,
- page_array[ram_pages]);
-
- freepage_array = &page_array[nr_pages - extra_pages];
+ page_array[nr_pages - 1]);
+
#elif defined(__ia64__)
- if ( xc_ia64_get_pfn_list(xc_handle, domid, page_array, 0, ram_pages)
- != ram_pages )
+ if ( xc_ia64_get_pfn_list(xc_handle, domid, page_array, 0, nr_pages)
+ != nr_pages)
{
fprintf(logfile, "xc_ia64_get_pfn_list returned error %d\n", errno);
exit(-1);
@@ -3221,7 +3059,7 @@ int main(int argc, char **argv)
if ( (phys_ram_base = xc_map_foreign_batch(xc_handle, domid,
PROT_READ|PROT_WRITE,
page_array,
- ram_pages)) == 0 )
+ nr_pages)) == 0 )
{
fprintf(logfile, "xc_map_foreign_batch returned error %d\n", errno);
exit(-1);
@@ -3229,7 +3067,7 @@ int main(int argc, char **argv)
if ( xc_ia64_get_pfn_list(xc_handle, domid,
page_array,
- ram_pages + (GFW_SIZE >> PAGE_SHIFT), 1) != 1 )
+ nr_pages + (GFW_SIZE >> PAGE_SHIFT), 1) != 1 )
{
fprintf(logfile, "xc_ia64_get_pfn_list returned error %d\n", errno);
exit(-1);
@@ -3396,7 +3234,7 @@ int main(int argc, char **argv)
#if defined(TARGET_I386)
pc_init(ram_size, vga_ram_size, boot_device,
ds, fd_filename, snapshot,
- kernel_filename, kernel_cmdline, initrd_filename);
+ kernel_filename, kernel_cmdline, initrd_filename, timeoffset);
#elif defined(TARGET_PPC)
ppc_init(ram_size, vga_ram_size, boot_device,
ds, fd_filename, snapshot,
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/ioemu/vl.h
--- a/tools/ioemu/vl.h Mon May 22 08:53:26 2006 -0600
+++ b/tools/ioemu/vl.h Mon May 22 14:13:38 2006 -0600
@@ -38,6 +38,8 @@
#include <fcntl.h>
#include <sys/stat.h>
#include "audio/audio.h"
+#include "xenctrl.h"
+#include "xs.h"
#ifndef O_LARGEFILE
#define O_LARGEFILE 0
@@ -113,6 +115,19 @@ void qemu_system_shutdown_request(void);
void main_loop_wait(int timeout);
+int unset_mm_mapping(int xc_handle,
+ uint32_t domid,
+ unsigned long nr_pages,
+ unsigned int address_bits,
+ unsigned long *extent_start);
+int set_mm_mapping(int xc_handle,
+ uint32_t domid,
+ unsigned long nr_pages,
+ unsigned int address_bits,
+ unsigned long *extent_start);
+
+extern int xc_handle;
+extern int domid;
extern int audio_enabled;
extern int sb16_enabled;
extern int adlib_enabled;
@@ -223,6 +238,7 @@ void console_select(unsigned int index);
/* serial ports */
#define MAX_SERIAL_PORTS 4
+#define SUMMA_PORT 1
extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
@@ -618,12 +634,6 @@ extern const char* keyboard_layout;
extern const char* keyboard_layout;
extern int repeat_key;
-/* Mice */
-
-void summa_init(void *cookie, CharDriverState *chr);
-
-extern int summa_ok;
-
/* mc146818rtc.c */
typedef struct RTCState RTCState;
@@ -637,6 +647,12 @@ typedef struct SerialState SerialState;
typedef struct SerialState SerialState;
SerialState *serial_init(int base, int irq, CharDriverState *chr);
void ser_queue(SerialState *s, unsigned char c);
+
+/* Mice */
+
+void summa_init(SerialState *serial, CharDriverState *chr);
+
+extern int summa_ok;
/* i8259.c */
@@ -663,7 +679,7 @@ void pc_init(uint64_t ram_size, int vga_
void pc_init(uint64_t ram_size, int vga_ram_size, int boot_device,
DisplayState *ds, const char **fd_filename, int snapshot,
const char *kernel_filename, const char *kernel_cmdline,
- const char *initrd_filename);
+ const char *initrd_filename, time_t timeoffset);
/* ppc.c */
void ppc_init (int ram_size, int vga_ram_size, int boot_device,
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/libxc/xc_acm.c
--- a/tools/libxc/xc_acm.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/libxc/xc_acm.c Mon May 22 14:13:38 2006 -0600
@@ -1,13 +1,10 @@
/******************************************************************************
+ * xc_acm.c
*
- * Copyright (C) 2005 IBM Corporation
+ * Copyright (C) 2005, 2006 IBM Corporation, R Sailer
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
- *
- * Authors:
- * Reiner Sailer <sailer@xxxxxxxxxxxxxx>
- * Stefan Berger <stefanb@xxxxxxxxxxxxxx>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -17,29 +14,23 @@
#include "xc_private.h"
-int xc_acm_op(int xc_handle, struct acm_op *op)
+
+int xc_acm_op(int xc_handle, int cmd, void *arg, size_t arg_size)
{
int ret = -1;
DECLARE_HYPERCALL;
- op->interface_version = ACM_INTERFACE_VERSION;
+ hypercall.op = __HYPERVISOR_acm_op;
+ hypercall.arg[0] = cmd;
+ hypercall.arg[1] = (unsigned long) arg;
- hypercall.op = __HYPERVISOR_acm_op;
- hypercall.arg[0] = (unsigned long) op;
-
- if (mlock(op, sizeof(*op)) != 0) {
- PERROR("Could not lock memory for Xen policy hypercall");
- goto out1;
+ if (mlock(arg, arg_size) != 0) {
+ PERROR("xc_acm_op: arg mlock failed");
+ goto out;
}
-
ret = do_xen_hypercall(xc_handle, &hypercall);
- ret = ioctl(xc_handle, IOCTL_PRIVCMD_HYPERCALL, &hypercall);
- if (ret < 0) {
- goto out2;
- }
- out2:
- safe_munlock(op, sizeof(*op));
- out1:
+ safe_munlock(arg, arg_size);
+ out:
return ret;
}
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/libxc/xc_linux_build.c Mon May 22 14:13:38 2006 -0600
@@ -327,6 +327,13 @@ static int setup_pg_tables_pae(int xc_ha
*vl1e &= ~_PAGE_RW;
}
vl1e++;
+ }
+
+ /* Xen requires a mid-level pgdir mapping 0xC0000000 region. */
+ if ( (vl3tab[3] & _PAGE_PRESENT) == 0 )
+ {
+ alloc_pt(l2tab, vl2tab, pl2tab);
+ vl3tab[3] = l2tab | L3_PROT;
}
munmap(vl1tab, PAGE_SIZE);
@@ -727,25 +734,28 @@ static int setup_guest(int xc_handle,
v_end = (vstack_end + (1UL<<22)-1) & ~((1UL<<22)-1);
if ( (v_end - vstack_end) < (512UL << 10) )
v_end += 1UL << 22; /* Add extra 4MB to get >= 512kB padding. */
-#if defined(__i386__)
- if ( dsi.pae_kernel )
- {
- /* FIXME: assumes one L2 pgtable @ 0xc0000000 */
- if ( (((v_end - dsi.v_start + ((1<<L2_PAGETABLE_SHIFT_PAE)-1)) >>
- L2_PAGETABLE_SHIFT_PAE) + 2) <= nr_pt_pages )
- break;
- }
- else
- {
- if ( (((v_end - dsi.v_start + ((1<<L2_PAGETABLE_SHIFT)-1)) >>
- L2_PAGETABLE_SHIFT) + 1) <= nr_pt_pages )
- break;
- }
-#endif
-#if defined(__x86_64__)
#define NR(_l,_h,_s) \
(((((_h) + ((1UL<<(_s))-1)) & ~((1UL<<(_s))-1)) - \
((_l) & ~((1UL<<(_s))-1))) >> (_s))
+#if defined(__i386__)
+ if ( dsi.pae_kernel )
+ {
+ if ( (1 + /* # L3 */
+ NR(dsi.v_start, v_end, L3_PAGETABLE_SHIFT_PAE) + /* # L2 */
+ NR(dsi.v_start, v_end, L2_PAGETABLE_SHIFT_PAE) + /* # L1 */
+ /* Include a fourth mid-level page directory for Xen. */
+ (v_end <= (3 << L3_PAGETABLE_SHIFT_PAE)))
+ <= nr_pt_pages )
+ break;
+ }
+ else
+ {
+ if ( (1 + /* # L2 */
+ NR(dsi.v_start, v_end, L2_PAGETABLE_SHIFT)) /* # L1 */
+ <= nr_pt_pages )
+ break;
+ }
+#elif defined(__x86_64__)
if ( (1 + /* # L4 */
NR(dsi.v_start, v_end, L4_PAGETABLE_SHIFT) + /* # L3 */
NR(dsi.v_start, v_end, L3_PAGETABLE_SHIFT) + /* # L2 */
@@ -794,9 +804,11 @@ static int setup_guest(int xc_handle,
goto error_out;
}
- (load_funcs.loadimage)(image, image_size,
+ rc = (load_funcs.loadimage)(image, image_size,
xc_handle, dom, page_array,
&dsi);
+ if ( rc != 0 )
+ goto error_out;
if ( load_initrd(xc_handle, dom, initrd,
vinitrd_start - dsi.v_start, page_array) )
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/libxc/xc_load_elf.c
--- a/tools/libxc/xc_load_elf.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/libxc/xc_load_elf.c Mon May 22 14:13:38 2006 -0600
@@ -58,10 +58,10 @@ static int parseelfimage(const char *ima
Elf_Ehdr *ehdr = (Elf_Ehdr *)image;
Elf_Phdr *phdr;
Elf_Shdr *shdr;
- unsigned long kernstart = ~0UL, kernend=0UL;
+ unsigned long kernstart = ~0UL, kernend=0UL, vaddr, virt_base, elf_pa_off;
const char *shstrtab;
char *guestinfo=NULL, *p;
- int h;
+ int h, virt_base_defined, elf_pa_off_defined;
if ( !IS_ELF(*ehdr) )
{
@@ -148,40 +148,65 @@ static int parseelfimage(const char *ima
dsi->xen_guest_string = guestinfo;
+ /* Initial guess for virt_base is 0 if it is not explicitly defined. */
+ p = strstr(guestinfo, "VIRT_BASE=");
+ virt_base_defined = (p != NULL);
+ virt_base = virt_base_defined ? strtoul(p+10, &p, 0) : 0;
+
+ /* Initial guess for elf_pa_off is virt_base if not explicitly defined. */
+ p = strstr(guestinfo, "ELF_PADDR_OFFSET=");
+ elf_pa_off_defined = (p != NULL);
+ elf_pa_off = elf_pa_off_defined ? strtoul(p+17, &p, 0) : virt_base;
+
+ if ( elf_pa_off_defined && !virt_base_defined )
+ goto bad_image;
+
for ( h = 0; h < ehdr->e_phnum; h++ )
{
phdr = (Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize));
if ( !is_loadable_phdr(phdr) )
continue;
- if ( phdr->p_paddr < kernstart )
- kernstart = phdr->p_paddr;
- if ( (phdr->p_paddr + phdr->p_memsz) > kernend )
- kernend = phdr->p_paddr + phdr->p_memsz;
- }
+ vaddr = phdr->p_paddr - elf_pa_off + virt_base;
+ if ( (vaddr + phdr->p_memsz) < vaddr )
+ goto bad_image;
+ if ( vaddr < kernstart )
+ kernstart = vaddr;
+ if ( (vaddr + phdr->p_memsz) > kernend )
+ kernend = vaddr + phdr->p_memsz;
+ }
+
+ /*
+ * Legacy compatibility and images with no __xen_guest section: assume
+ * header addresses are virtual addresses, and that guest memory should be
+ * mapped starting at kernel load address.
+ */
+ dsi->v_start = virt_base_defined ? virt_base : kernstart;
+ dsi->elf_paddr_offset = elf_pa_off_defined ? elf_pa_off : dsi->v_start;
+
+ dsi->v_kernentry = ehdr->e_entry;
+ if ( (p = strstr(guestinfo, "VIRT_ENTRY=")) != NULL )
+ dsi->v_kernentry = strtoul(p+11, &p, 0);
if ( (kernstart > kernend) ||
- (ehdr->e_entry < kernstart) ||
- (ehdr->e_entry > kernend) )
- {
- ERROR("Malformed ELF image.");
- return -EINVAL;
- }
-
- dsi->v_start = kernstart;
- if ( (p = strstr(guestinfo, "VIRT_BASE=")) != NULL )
- dsi->v_start = strtoul(p+10, &p, 0);
+ (dsi->v_kernentry < kernstart) ||
+ (dsi->v_kernentry > kernend) ||
+ (dsi->v_start > kernstart) )
+ goto bad_image;
if ( (p = strstr(guestinfo, "BSD_SYMTAB")) != NULL )
dsi->load_symtab = 1;
dsi->v_kernstart = kernstart;
dsi->v_kernend = kernend;
- dsi->v_kernentry = ehdr->e_entry;
dsi->v_end = dsi->v_kernend;
loadelfsymtab(image, 0, 0, NULL, dsi);
return 0;
+
+ bad_image:
+ ERROR("Malformed ELF image.");
+ return -EINVAL;
}
static int
@@ -204,9 +229,11 @@ loadelfimage(
for ( done = 0; done < phdr->p_filesz; done += chunksz )
{
- pa = (phdr->p_paddr + done) - dsi->v_start;
+ pa = (phdr->p_paddr + done) - dsi->elf_paddr_offset;
va = xc_map_foreign_range(
xch, dom, PAGE_SIZE, PROT_WRITE, parray[pa>>PAGE_SHIFT]);
+ if ( va == NULL )
+ return -1;
chunksz = phdr->p_filesz - done;
if ( chunksz > (PAGE_SIZE - (pa & (PAGE_SIZE-1))) )
chunksz = PAGE_SIZE - (pa & (PAGE_SIZE-1));
@@ -217,9 +244,11 @@ loadelfimage(
for ( ; done < phdr->p_memsz; done += chunksz )
{
- pa = (phdr->p_paddr + done) - dsi->v_start;
+ pa = (phdr->p_paddr + done) - dsi->elf_paddr_offset;
va = xc_map_foreign_range(
xch, dom, PAGE_SIZE, PROT_WRITE, parray[pa>>PAGE_SHIFT]);
+ if ( va == NULL )
+ return -1;
chunksz = phdr->p_memsz - done;
if ( chunksz > (PAGE_SIZE - (pa & (PAGE_SIZE-1))) )
chunksz = PAGE_SIZE - (pa & (PAGE_SIZE-1));
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/libxc/xc_ptrace.c
--- a/tools/libxc/xc_ptrace.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/libxc/xc_ptrace.c Mon May 22 14:13:38 2006 -0600
@@ -157,6 +157,27 @@ static long nr_pages
static long nr_pages = 0;
static unsigned long *page_array = NULL;
+
+/*
+ * Translates physical addresses to machine addresses for HVM
+ * guests. For paravirtual domains the function will just return the
+ * given address.
+ *
+ * This function should be used when reading page directories/page
+ * tables.
+ *
+ */
+static unsigned long
+to_ma(int cpu,
+ unsigned long in_addr)
+{
+ unsigned long maddr = in_addr;
+
+ if ( (ctxt[cpu].flags & VGCF_HVM_GUEST) && paging_enabled(&ctxt[cpu]) )
+ maddr = page_array[maddr >> PAGE_SHIFT] << PAGE_SHIFT;
+ return maddr;
+}
+
static void *
map_domain_va_32(
int xc_handle,
@@ -164,66 +185,34 @@ map_domain_va_32(
void *guest_va,
int perm)
{
- unsigned long pde, page;
- unsigned long va = (unsigned long)guest_va;
-
- static unsigned long cr3_phys[MAX_VIRT_CPUS];
- static uint32_t *cr3_virt[MAX_VIRT_CPUS];
- static unsigned long pde_phys[MAX_VIRT_CPUS];
- static uint32_t *pde_virt[MAX_VIRT_CPUS];
- static unsigned long page_phys[MAX_VIRT_CPUS];
- static uint32_t *page_virt[MAX_VIRT_CPUS];
- static int prev_perm[MAX_VIRT_CPUS];
-
- if (ctxt[cpu].ctrlreg[3] == 0)
- return NULL;
- if ( ctxt[cpu].ctrlreg[3] != cr3_phys[cpu] )
- {
- cr3_phys[cpu] = ctxt[cpu].ctrlreg[3];
- if ( cr3_virt[cpu] )
- munmap(cr3_virt[cpu], PAGE_SIZE);
- cr3_virt[cpu] = xc_map_foreign_range(
- xc_handle, current_domid, PAGE_SIZE, PROT_READ,
- cr3_phys[cpu] >> PAGE_SHIFT);
- if ( cr3_virt[cpu] == NULL )
- return NULL;
- }
- if ( (pde = cr3_virt[cpu][vtopdi(va)]) == 0 )
- return NULL;
- if ( (ctxt[cpu].flags & VGCF_HVM_GUEST) && paging_enabled(&ctxt[cpu]) )
- pde = page_array[pde >> PAGE_SHIFT] << PAGE_SHIFT;
- if ( pde != pde_phys[cpu] )
- {
- pde_phys[cpu] = pde;
- if ( pde_virt[cpu] )
- munmap(pde_virt[cpu], PAGE_SIZE);
- pde_virt[cpu] = xc_map_foreign_range(
- xc_handle, current_domid, PAGE_SIZE, PROT_READ,
- pde_phys[cpu] >> PAGE_SHIFT);
- if ( pde_virt[cpu] == NULL )
- return NULL;
- }
- if ( (page = pde_virt[cpu][vtopti(va)]) == 0 )
- return NULL;
- if (ctxt[cpu].flags & VGCF_HVM_GUEST)
- page = page_array[page >> PAGE_SHIFT] << PAGE_SHIFT;
- if ( (page != page_phys[cpu]) || (perm != prev_perm[cpu]) )
- {
- page_phys[cpu] = page;
- if ( page_virt[cpu] )
- munmap(page_virt[cpu], PAGE_SIZE);
- page_virt[cpu] = xc_map_foreign_range(
- xc_handle, current_domid, PAGE_SIZE, perm,
- page_phys[cpu] >> PAGE_SHIFT);
- if ( page_virt[cpu] == NULL )
- {
- page_phys[cpu] = 0;
- return NULL;
- }
- prev_perm[cpu] = perm;
- }
-
- return (void *)(((unsigned long)page_virt[cpu]) | (va & BSD_PAGE_MASK));
+ unsigned long l1p, p, va = (unsigned long)guest_va;
+ uint32_t *l2, *l1;
+ static void *v[MAX_VIRT_CPUS];
+
+ l2 = xc_map_foreign_range(
+ xc_handle, current_domid, PAGE_SIZE, PROT_READ, ctxt[cpu].ctrlreg[3]
>> PAGE_SHIFT);
+ if ( l2 == NULL )
+ return NULL;
+
+ l1p = to_ma(cpu, l2[l2_table_offset(va)]);
+ munmap(l2, PAGE_SIZE);
+ if ( !(l1p & _PAGE_PRESENT) )
+ return NULL;
+ l1 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, PROT_READ,
l1p >> PAGE_SHIFT);
+ if ( l1 == NULL )
+ return NULL;
+
+ p = to_ma(cpu, l1[l1_table_offset(va)]);
+ munmap(l1, PAGE_SIZE);
+ if ( !(p & _PAGE_PRESENT) )
+ return NULL;
+ if ( v[cpu] != NULL )
+ munmap(v[cpu], PAGE_SIZE);
+ v[cpu] = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, p
>> PAGE_SHIFT);
+ if ( v[cpu] == NULL )
+ return NULL;
+
+ return (void *)((unsigned long)v[cpu] | (va & (PAGE_SIZE - 1)));
}
@@ -236,37 +225,40 @@ map_domain_va_pae(
{
unsigned long l2p, l1p, p, va = (unsigned long)guest_va;
uint64_t *l3, *l2, *l1;
- static void *v;
+ static void *v[MAX_VIRT_CPUS];
l3 = xc_map_foreign_range(
xc_handle, current_domid, PAGE_SIZE, PROT_READ, ctxt[cpu].ctrlreg[3]
>> PAGE_SHIFT);
if ( l3 == NULL )
return NULL;
- l2p = l3[l3_table_offset_pae(va)] >> PAGE_SHIFT;
- l2p = page_array[l2p];
- l2 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, PROT_READ,
l2p);
+ l2p = to_ma(cpu, l3[l3_table_offset_pae(va)]);
munmap(l3, PAGE_SIZE);
+ if ( !(l2p & _PAGE_PRESENT) )
+ return NULL;
+ l2 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, PROT_READ,
l2p >> PAGE_SHIFT);
if ( l2 == NULL )
return NULL;
- l1p = l2[l2_table_offset_pae(va)] >> PAGE_SHIFT;
- l1p = page_array[l1p];
- l1 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, l1p);
+ l1p = to_ma(cpu, l2[l2_table_offset_pae(va)]);
munmap(l2, PAGE_SIZE);
+ if ( !(l1p & _PAGE_PRESENT) )
+ return NULL;
+ l1 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, l1p
>> PAGE_SHIFT);
if ( l1 == NULL )
return NULL;
- p = l1[l1_table_offset_pae(va)] >> PAGE_SHIFT;
- p = page_array[p];
- if ( v != NULL )
- munmap(v, PAGE_SIZE);
- v = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, p);
+ p = to_ma(cpu, l1[l1_table_offset_pae(va)]);
munmap(l1, PAGE_SIZE);
- if ( v == NULL )
- return NULL;
-
- return (void *)((unsigned long)v | (va & (PAGE_SIZE - 1)));
+ if ( !(p & _PAGE_PRESENT) )
+ return NULL;
+ if ( v[cpu] != NULL )
+ munmap(v[cpu], PAGE_SIZE);
+ v[cpu] = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, p
>> PAGE_SHIFT);
+ if ( v[cpu] == NULL )
+ return NULL;
+
+ return (void *)((unsigned long)v[cpu] | (va & (PAGE_SIZE - 1)));
}
#ifdef __x86_64__
@@ -279,7 +271,7 @@ map_domain_va_64(
{
unsigned long l3p, l2p, l1p, l1e, p, va = (unsigned long)guest_va;
uint64_t *l4, *l3, *l2, *l1;
- static void *v;
+ static void *v[MAX_VIRT_CPUS];
if ((ctxt[cpu].ctrlreg[4] & 0x20) == 0 ) /* legacy ia32 mode */
return map_domain_va_32(xc_handle, cpu, guest_va, perm);
@@ -289,44 +281,50 @@ map_domain_va_64(
if ( l4 == NULL )
return NULL;
- l3p = l4[l4_table_offset(va)] >> PAGE_SHIFT;
- l3p = page_array[l3p];
- l3 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, PROT_READ,
l3p);
+ l3p = to_ma(cpu, l4[l4_table_offset(va)]);
munmap(l4, PAGE_SIZE);
+ if ( !(l3p & _PAGE_PRESENT) )
+ return NULL;
+ l3 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, PROT_READ,
l3p >> PAGE_SHIFT);
if ( l3 == NULL )
return NULL;
- l2p = l3[l3_table_offset(va)] >> PAGE_SHIFT;
- l2p = page_array[l2p];
- l2 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, PROT_READ,
l2p);
+ l2p = to_ma(cpu, l3[l3_table_offset(va)]);
munmap(l3, PAGE_SIZE);
+ if ( !(l2p & _PAGE_PRESENT) )
+ return NULL;
+ l2 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, PROT_READ,
l2p >> PAGE_SHIFT);
if ( l2 == NULL )
return NULL;
l1 = NULL;
- l1e = l2[l2_table_offset(va)];
+ l1e = to_ma(cpu, l2[l2_table_offset(va)]);
+ if ( !(l1e & _PAGE_PRESENT) )
+ {
+ munmap(l2, PAGE_SIZE);
+ return NULL;
+ }
l1p = l1e >> PAGE_SHIFT;
if (l1e & 0x80) { /* 2M pages */
- p = (l1p + l1_table_offset(va));
+ p = to_ma(cpu, (l1p + l1_table_offset(va)) << PAGE_SHIFT);
} else { /* 4K pages */
- l1p = page_array[l1p];
- l1 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm,
l1p);
+ l1p = to_ma(cpu, l1p);
+ l1 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm,
l1p >> PAGE_SHIFT);
munmap(l2, PAGE_SIZE);
if ( l1 == NULL )
return NULL;
- p = l1[l1_table_offset(va)] >> PAGE_SHIFT;
- }
- p = page_array[p];
- if ( v != NULL )
- munmap(v, PAGE_SIZE);
- v = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, p);
+ p = to_ma(cpu, l1[l1_table_offset(va)]);
+ }
+ if ( v[cpu] != NULL )
+ munmap(v[cpu], PAGE_SIZE);
+ v[cpu] = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, p
>> PAGE_SHIFT);
if (l1)
munmap(l1, PAGE_SIZE);
- if ( v == NULL )
- return NULL;
-
- return (void *)((unsigned long)v | (va & (PAGE_SIZE - 1)));
+ if ( v[cpu] == NULL )
+ return NULL;
+
+ return (void *)((unsigned long)v[cpu] | (va & (PAGE_SIZE - 1)));
}
#endif
@@ -381,7 +379,7 @@ map_domain_va(
if ( v != NULL )
munmap(v, PAGE_SIZE);
- page = page_array[va >> PAGE_SHIFT] << PAGE_SHIFT;
+ page = to_ma(cpu, page_array[va >> PAGE_SHIFT]);
v = xc_map_foreign_range( xc_handle, current_domid, PAGE_SIZE,
perm, page >> PAGE_SHIFT);
@@ -510,6 +508,11 @@ xc_ptrace(
break;
case PTRACE_GETFPREGS:
+ if (!current_isfile && fetch_regs(xc_handle, cpu, NULL))
+ goto out_error;
+ memcpy(data, &ctxt[cpu].fpu_ctxt, sizeof (elf_fpregset_t));
+ break;
+
case PTRACE_GETFPXREGS:
if (!current_isfile && fetch_regs(xc_handle, cpu, NULL))
goto out_error;
@@ -518,7 +521,7 @@ xc_ptrace(
case PTRACE_SETREGS:
if (current_isfile)
- goto out_unspported; /* XXX not yet supported */
+ goto out_unsupported; /* XXX not yet supported */
SET_XC_REGS(((struct gdb_regs *)data), ctxt[cpu].user_regs);
if ((retval = xc_vcpu_setcontext(xc_handle, current_domid, cpu,
&ctxt[cpu])))
@@ -526,8 +529,8 @@ xc_ptrace(
break;
case PTRACE_SINGLESTEP:
- if (!current_isfile)
- goto out_unspported; /* XXX not yet supported */
+ if (current_isfile)
+ goto out_unsupported; /* XXX not yet supported */
/* XXX we can still have problems if the user switches threads
* during single-stepping - but that just seems retarded
*/
@@ -540,7 +543,7 @@ xc_ptrace(
case PTRACE_CONT:
case PTRACE_DETACH:
if (current_isfile)
- goto out_unspported; /* XXX not yet supported */
+ goto out_unsupported; /* XXX not yet supported */
if ( request != PTRACE_SINGLESTEP )
{
FOREACH_CPU(cpumap, index) {
@@ -603,7 +606,7 @@ xc_ptrace(
case PTRACE_POKEUSER:
case PTRACE_SYSCALL:
case PTRACE_KILL:
- goto out_unspported; /* XXX not yet supported */
+ goto out_unsupported; /* XXX not yet supported */
case PTRACE_TRACEME:
printf("PTRACE_TRACEME is an invalid request under Xen\n");
@@ -618,7 +621,7 @@ xc_ptrace(
errno = EINVAL;
return retval;
- out_unspported:
+ out_unsupported:
#ifdef DEBUG
printf("unsupported xc_ptrace request %s\n", ptrace_names[request]);
#endif
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/libxc/xc_tbuf.c
--- a/tools/libxc/xc_tbuf.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/libxc/xc_tbuf.c Mon May 22 14:13:38 2006 -0600
@@ -16,7 +16,7 @@
#include "xc_private.h"
-int xc_tbuf_enable(int xc_handle, int enable)
+static int tbuf_enable(int xc_handle, int enable)
{
DECLARE_DOM0_OP;
@@ -30,7 +30,7 @@ int xc_tbuf_enable(int xc_handle, int en
return xc_dom0_op(xc_handle, &op);
}
-int xc_tbuf_set_size(int xc_handle, uint32_t size)
+int xc_tbuf_set_size(int xc_handle, unsigned long size)
{
DECLARE_DOM0_OP;
@@ -42,7 +42,7 @@ int xc_tbuf_set_size(int xc_handle, uint
return xc_dom0_op(xc_handle, &op);
}
-int xc_tbuf_get_size(int xc_handle, uint32_t *size)
+int xc_tbuf_get_size(int xc_handle, unsigned long *size)
{
int rc;
DECLARE_DOM0_OP;
@@ -57,10 +57,17 @@ int xc_tbuf_get_size(int xc_handle, uint
return rc;
}
-int xc_tbuf_get_mfn(int xc_handle, unsigned long *mfn)
+int xc_tbuf_enable(int xc_handle, size_t cnt, unsigned long *mfn,
+ unsigned long *size)
{
+ DECLARE_DOM0_OP;
int rc;
- DECLARE_DOM0_OP;
+
+ if ( xc_tbuf_set_size(xc_handle, cnt) != 0 )
+ return -1;
+
+ if ( tbuf_enable(xc_handle, 1) != 0 )
+ return -1;
op.cmd = DOM0_TBUFCONTROL;
op.interface_version = DOM0_INTERFACE_VERSION;
@@ -68,8 +75,17 @@ int xc_tbuf_get_mfn(int xc_handle, unsig
rc = xc_dom0_op(xc_handle, &op);
if ( rc == 0 )
- *mfn = op.u.tbufcontrol.buffer_mfn;
- return rc;
+ {
+ *size = op.u.tbufcontrol.size;
+ *mfn = op.u.tbufcontrol.buffer_mfn;
+ }
+
+ return 0;
+}
+
+int xc_tbuf_disable(int xc_handle)
+{
+ return tbuf_enable(xc_handle, 0);
}
int xc_tbuf_set_cpu_mask(int xc_handle, uint32_t mask)
@@ -95,3 +111,4 @@ int xc_tbuf_set_evt_mask(int xc_handle,
return do_dom0_op(xc_handle, &op);
}
+
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h Mon May 22 08:53:26 2006 -0600
+++ b/tools/libxc/xenctrl.h Mon May 22 14:13:38 2006 -0600
@@ -9,6 +9,7 @@
#ifndef XENCTRL_H
#define XENCTRL_H
+#include <stddef.h>
#include <stdint.h>
#include <sys/ptrace.h>
#include <xen/xen.h>
@@ -529,15 +530,23 @@ long xc_get_tot_pages(int xc_handle, uin
*/
/**
- * This function enables or disables tracing. Trace buffer memory must
- * be already allocated by setting the size to a non-zero value, otherwise
- * tracing cannot be enabled.
- *
- * @parm xc_handle a handle to an open hypervisor interface
- * @parm enable the desired action, 1 for enable, 0 for disable
- * @return 0 on success, -1 on failure.
- */
-int xc_tbuf_enable(int xc_handle, int enable);
+ * xc_tbuf_enable - enable tracing buffers
+ *
+ * @parm xc_handle a handle to an open hypervisor interface
+ * @parm cnt size of tracing buffers to create (in pages)
+ * @parm mfn location to store mfn of the trace buffers to
+ * @parm size location to store the size (in bytes) of a trace buffer to
+ *
+ * Gets the machine address of the trace pointer area and the size of the
+ * per CPU buffers.
+ */
+int xc_tbuf_enable(int xc_handle, size_t cnt, unsigned long *mfn,
+ unsigned long *size);
+
+/*
+ * Disable tracing buffers.
+ */
+int xc_tbuf_disable(int xc_handle);
/**
* This function sets the size of the trace buffers. Setting the size
@@ -549,7 +558,7 @@ int xc_tbuf_enable(int xc_handle, int en
* @parm size the size in pages per cpu for the trace buffers
* @return 0 on success, -1 on failure.
*/
-int xc_tbuf_set_size(int xc_handle, uint32_t size);
+int xc_tbuf_set_size(int xc_handle, unsigned long size);
/**
* This function retrieves the current size of the trace buffers.
@@ -559,16 +568,7 @@ int xc_tbuf_set_size(int xc_handle, uint
* @parm size will contain the size in bytes for the trace buffers
* @return 0 on success, -1 on failure.
*/
-int xc_tbuf_get_size(int xc_handle, uint32_t *size);
-
-/**
- * This function retrieves the machine frame of the trace buffer.
-
- * @parm xc_handle a handle to an open hypervisor interface
- * @parm mfn will contain the machine frame of the buffer.
- * @return 0 on success, -1 on failure.
- */
-int xc_tbuf_get_mfn(int xc_handle, unsigned long *mfn);
+int xc_tbuf_get_size(int xc_handle, unsigned long *size);
int xc_tbuf_set_cpu_mask(int xc_handle, uint32_t mask);
@@ -594,6 +594,6 @@ int xc_add_mmu_update(int xc_handle, xc_
unsigned long long ptr, unsigned long long val);
int xc_finish_mmu_updates(int xc_handle, xc_mmu_t *mmu);
-int xc_acm_op(int xc_handle, struct acm_op *op);
+int xc_acm_op(int xc_handle, int cmd, void *arg, size_t arg_size);
#endif
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/libxc/xg_private.h
--- a/tools/libxc/xg_private.h Mon May 22 08:53:26 2006 -0600
+++ b/tools/libxc/xg_private.h Mon May 22 14:13:38 2006 -0600
@@ -136,8 +136,11 @@ struct domain_setup_info
unsigned long v_kernend;
unsigned long v_kernentry;
+ unsigned long elf_paddr_offset;
+
+ unsigned int pae_kernel;
+
unsigned int load_symtab;
- unsigned int pae_kernel;
unsigned long symtab_addr;
unsigned long symtab_len;
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/python/xen/lowlevel/acm/acm.c
--- a/tools/python/xen/lowlevel/acm/acm.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/python/xen/lowlevel/acm/acm.c Mon May 22 14:13:38 2006 -0600
@@ -38,7 +38,7 @@ fprintf(stderr, "ERROR: " _m " (%d = %s)
/* generic shared function */
void * __getssid(int domid, uint32_t *buflen)
{
- struct acm_op op;
+ struct acm_getssid getssid;
int xc_handle;
#define SSID_BUFFER_SIZE 4096
void *buf = NULL;
@@ -51,14 +51,13 @@ void * __getssid(int domid, uint32_t *bu
goto out2;
}
memset(buf, 0, SSID_BUFFER_SIZE);
- op.cmd = ACM_GETSSID;
- op.interface_version = ACM_INTERFACE_VERSION;
- op.u.getssid.ssidbuf = buf;
- op.u.getssid.ssidbuf_size = SSID_BUFFER_SIZE;
- op.u.getssid.get_ssid_by = DOMAINID;
- op.u.getssid.id.domainid = domid;
-
- if (xc_acm_op(xc_handle, &op) < 0) {
+ getssid.interface_version = ACM_INTERFACE_VERSION;
+ getssid.ssidbuf = buf;
+ getssid.ssidbuf_size = SSID_BUFFER_SIZE;
+ getssid.get_ssid_by = DOMAINID;
+ getssid.id.domainid = domid;
+
+ if (xc_acm_op(xc_handle, ACMOP_getssid, &getssid, sizeof(getssid)) < 0) {
if (errno == EACCES)
PERROR("ACM operation failed.");
free(buf);
@@ -147,7 +146,7 @@ static PyObject *getdecision(PyObject *
static PyObject *getdecision(PyObject * self, PyObject * args)
{
char *arg1_name, *arg1, *arg2_name, *arg2, *decision = NULL;
- struct acm_op op;
+ struct acm_getdecision getdecision;
int xc_handle;
if (!PyArg_ParseTuple(args, "ssss", &arg1_name, &arg1, &arg2_name, &arg2))
{
@@ -163,34 +162,33 @@ static PyObject *getdecision(PyObject *
(strcmp(arg2_name, "domid") && strcmp(arg2_name, "ssidref")))
return NULL;
- op.cmd = ACM_GETDECISION;
- op.interface_version = ACM_INTERFACE_VERSION;
- op.u.getdecision.hook = SHARING;
+ getdecision.interface_version = ACM_INTERFACE_VERSION;
+ getdecision.hook = SHARING;
if (!strcmp(arg1_name, "domid")) {
- op.u.getdecision.get_decision_by1 = DOMAINID;
- op.u.getdecision.id1.domainid = atoi(arg1);
- } else {
- op.u.getdecision.get_decision_by1 = SSIDREF;
- op.u.getdecision.id1.ssidref = atol(arg1);
+ getdecision.get_decision_by1 = DOMAINID;
+ getdecision.id1.domainid = atoi(arg1);
+ } else {
+ getdecision.get_decision_by1 = SSIDREF;
+ getdecision.id1.ssidref = atol(arg1);
}
if (!strcmp(arg2_name, "domid")) {
- op.u.getdecision.get_decision_by2 = DOMAINID;
- op.u.getdecision.id2.domainid = atoi(arg2);
- } else {
- op.u.getdecision.get_decision_by2 = SSIDREF;
- op.u.getdecision.id2.ssidref = atol(arg2);
- }
-
- if (xc_acm_op(xc_handle, &op) < 0) {
+ getdecision.get_decision_by2 = DOMAINID;
+ getdecision.id2.domainid = atoi(arg2);
+ } else {
+ getdecision.get_decision_by2 = SSIDREF;
+ getdecision.id2.ssidref = atol(arg2);
+ }
+
+ if (xc_acm_op(xc_handle, ACMOP_getdecision, &getdecision,
sizeof(getdecision)) < 0) {
if (errno == EACCES)
PERROR("ACM operation failed.");
}
xc_interface_close(xc_handle);
- if (op.u.getdecision.acm_decision == ACM_ACCESS_PERMITTED)
+ if (getdecision.acm_decision == ACM_ACCESS_PERMITTED)
decision = "PERMITTED";
- else if (op.u.getdecision.acm_decision == ACM_ACCESS_DENIED)
+ else if (getdecision.acm_decision == ACM_ACCESS_DENIED)
decision = "DENIED";
return Py_BuildValue("s", decision);
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/python/xen/lowlevel/xc/xc.c Mon May 22 14:13:38 2006 -0600
@@ -1172,7 +1172,7 @@ PyXc_init(XcObject *self, PyObject *args
PyXc_init(XcObject *self, PyObject *args, PyObject *kwds)
{
if ((self->xc_handle = xc_interface_open()) == -1) {
- PyErr_SetFromErrno(PyExc_RuntimeError);
+ PyErr_SetFromErrno(xc_error);
return -1;
}
@@ -1245,7 +1245,7 @@ PyMODINIT_FUNC initxc(void)
if (m == NULL)
return;
- xc_error = PyErr_NewException(PKG ".error", NULL, NULL);
+ xc_error = PyErr_NewException(PKG ".Error", PyExc_RuntimeError, NULL);
zero = PyInt_FromLong(0);
/* KAF: This ensures that we get debug output in a timely manner. */
@@ -1254,6 +1254,9 @@ PyMODINIT_FUNC initxc(void)
Py_INCREF(&PyXcType);
PyModule_AddObject(m, CLS, (PyObject *)&PyXcType);
+
+ Py_INCREF(xc_error);
+ PyModule_AddObject(m, "Error", xc_error);
}
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/python/xen/xend/XendCheckpoint.py
--- a/tools/python/xen/xend/XendCheckpoint.py Mon May 22 08:53:26 2006 -0600
+++ b/tools/python/xen/xend/XendCheckpoint.py Mon May 22 14:13:38 2006 -0600
@@ -54,7 +54,7 @@ def read_exact(fd, size, errmsg):
-def save(fd, dominfo, live, dst):
+def save(fd, dominfo, network, live, dst):
write_exact(fd, SIGNATURE, "could not write guest state file: signature")
config = sxp.to_string(dominfo.sxpr())
@@ -66,7 +66,7 @@ def save(fd, dominfo, live, dst):
dominfo.setName('migrating-' + domain_name)
try:
- dominfo.migrateDevices(live, dst, DEV_MIGRATE_STEP1, domain_name)
+ dominfo.migrateDevices(network, dst, DEV_MIGRATE_STEP1, domain_name)
write_exact(fd, pack("!i", len(config)),
"could not write guest state file: config len")
@@ -88,10 +88,10 @@ def save(fd, dominfo, live, dst):
log.debug("Suspending %d ...", dominfo.getDomid())
dominfo.shutdown('suspend')
dominfo.waitForShutdown()
- dominfo.migrateDevices(live, dst, DEV_MIGRATE_STEP2,
+ dominfo.migrateDevices(network, dst, DEV_MIGRATE_STEP2,
domain_name)
log.info("Domain %d suspended.", dominfo.getDomid())
- dominfo.migrateDevices(live, dst, DEV_MIGRATE_STEP3,
+ dominfo.migrateDevices(network, dst, DEV_MIGRATE_STEP3,
domain_name)
tochild.write("done\n")
tochild.flush()
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py Mon May 22 08:53:26 2006 -0600
+++ b/tools/python/xen/xend/XendDomain.py Mon May 22 14:13:38 2006 -0600
@@ -408,7 +408,7 @@ class XendDomain:
raise XendError("Cannot migrate privileged domain %i" % domid)
""" The following call may raise a XendError exception """
- dominfo.testMigrateDevices(live, dst)
+ dominfo.testMigrateDevices(True, dst)
if port == 0:
port = xroot.get_xend_relocation_port()
@@ -420,7 +420,7 @@ class XendDomain:
sock.send("receive\n")
sock.recv(80)
- XendCheckpoint.save(sock.fileno(), dominfo, live, dst)
+ XendCheckpoint.save(sock.fileno(), dominfo, True, live, dst)
def domain_save(self, domid, dst):
@@ -440,7 +440,7 @@ class XendDomain:
fd = os.open(dst, os.O_WRONLY | os.O_CREAT | os.O_TRUNC)
try:
# For now we don't support 'live checkpoint'
- return XendCheckpoint.save(fd, dominfo, False, dst)
+ return XendCheckpoint.save(fd, dominfo, False, False, dst)
finally:
os.close(fd)
except OSError, ex:
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Mon May 22 08:53:26 2006 -0600
+++ b/tools/python/xen/xend/XendDomainInfo.py Mon May 22 14:13:38 2006 -0600
@@ -29,6 +29,7 @@ import string
import string
import time
import threading
+import os
import xen.lowlevel.xc
from xen.util import asserts
@@ -1264,7 +1265,14 @@ class XendDomainInfo:
m = self.image.getDomainMemory(self.info['memory'] * 1024)
balloon.free(m)
xc.domain_setmaxmem(self.domid, m)
- xc.domain_memory_increase_reservation(self.domid, m, 0, 0)
+
+ init_reservation = self.info['memory'] * 1024
+ if os.uname()[4] == 'ia64':
+ # Workaround until ia64 properly supports ballooning.
+ init_reservation = m
+
+ xc.domain_memory_increase_reservation(self.domid, init_reservation,
+ 0, 0)
self.createChannels()
@@ -1443,36 +1451,40 @@ class XendDomainInfo:
## public:
- def testMigrateDevices(self, live, dst):
+ def testMigrateDevices(self, network, dst):
""" Notify all device about intention of migration
@raise: XendError for a device that cannot be migrated
"""
for (n, c) in self.info['device']:
- rc = self.migrateDevice(n, c, live, dst, DEV_MIGRATE_TEST)
+ rc = self.migrateDevice(n, c, network, dst, DEV_MIGRATE_TEST)
if rc != 0:
raise XendError("Device of type '%s' refuses migration." % n)
- def migrateDevices(self, live, dst, step, domName=''):
+ def migrateDevices(self, network, dst, step, domName=''):
"""Notify the devices about migration
"""
ctr = 0
try:
for (n, c) in self.info['device']:
- self.migrateDevice(n, c, live, dst, step, domName)
+ self.migrateDevice(n, c, network, dst, step, domName)
ctr = ctr + 1
except:
for (n, c) in self.info['device']:
if ctr == 0:
step = step - 1
ctr = ctr - 1
- self.recoverMigrateDevice(n, c, live, dst, step, domName)
+ self.recoverMigrateDevice(n, c, network, dst, step, domName)
raise
- def migrateDevice(self, deviceClass, deviceConfig, live, dst, step,
domName=''):
- return self.getDeviceController(deviceClass).migrate(deviceConfig,
live, dst, step, domName)
-
- def recoverMigrateDevice(self, deviceClass, deviceConfig, live, dst, step,
domName=''):
- return
self.getDeviceController(deviceClass).recover_migrate(deviceConfig, live, dst,
step, domName)
+ def migrateDevice(self, deviceClass, deviceConfig, network, dst,
+ step, domName=''):
+ return self.getDeviceController(deviceClass).migrate(deviceConfig,
+ network, dst, step, domName)
+
+ def recoverMigrateDevice(self, deviceClass, deviceConfig, network,
+ dst, step, domName=''):
+ return self.getDeviceController(deviceClass).recover_migrate(
+ deviceConfig, network, dst, step, domName)
def waitForDevices(self):
"""Wait for this domain's configured devices to connect.
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py Mon May 22 08:53:26 2006 -0600
+++ b/tools/python/xen/xend/image.py Mon May 22 14:13:38 2006 -0600
@@ -19,6 +19,7 @@
import os, string
import re
+import math
import xen.lowlevel.xc
from xen.xend import sxp
@@ -141,11 +142,16 @@ class ImageHandler:
% (self.ostype, self.vm.getDomid(), str(result)))
- def getDomainMemory(self, mem):
+ def getDomainMemory(self, mem_kb):
"""@return The memory required, in KiB, by the domain to store the
- given amount, also in KiB. This is normally just mem, but HVM domains
- have overheads to account for."""
- return mem
+ given amount, also in KiB."""
+ if os.uname()[4] != 'ia64':
+ # A little extra because auto-ballooning is broken w.r.t. HVM
+ # guests. Also, slack is necessary for live migration since that
+ # uses shadow page tables.
+ if 'hvm' in xc.xeninfo()['xen_caps']:
+ mem_kb += 4*1024;
+ return mem_kb
def buildDomain(self):
"""Build the domain. Define in subclass."""
@@ -377,15 +383,20 @@ class HVMImageHandler(ImageHandler):
os.waitpid(self.pid, 0)
self.pid = 0
- def getDomainMemory(self, mem):
+ def getDomainMemory(self, mem_kb):
"""@see ImageHandler.getDomainMemory"""
- page_kb = 4
- extra_pages = 0
if os.uname()[4] == 'ia64':
page_kb = 16
# ROM size for guest firmware, ioreq page and xenstore page
extra_pages = 1024 + 2
- return mem + extra_pages * page_kb
+ else:
+ page_kb = 4
+ # This was derived emperically:
+ # 2.4 MB overhead per 1024 MB RAM + 8 MB constant
+ # + 4 to avoid low-memory condition
+ extra_mb = (2.4/1024) * (mem_kb/1024.0) + 12;
+ extra_pages = int( math.ceil( extra_mb*1024 / page_kb ))
+ return mem_kb + extra_pages * page_kb
def register_shutdown_watch(self):
""" add xen store watch on control/shutdown """
diff -r fbf676a36ee4 -r 72c5d8206d48
tools/python/xen/xend/server/DevController.py
--- a/tools/python/xen/xend/server/DevController.py Mon May 22 08:53:26
2006 -0600
+++ b/tools/python/xen/xend/server/DevController.py Mon May 22 14:13:38
2006 -0600
@@ -267,9 +267,9 @@ class DevController:
raise NotImplementedError()
- def migrate(self, deviceConfig, live, dst, step, domName):
- """ Migration of a device. The 'live' parameter indicates
- whether the device is live-migrated (live=1). 'dst' then gives
+ def migrate(self, deviceConfig, network, dst, step, domName):
+ """ Migration of a device. The 'network' parameter indicates
+ whether the device is network-migrated (True). 'dst' then gives
the hostname of the machine to migrate to.
This function is called for 4 steps:
If step == 0: Check whether the device is ready to be migrated
@@ -296,7 +296,7 @@ class DevController:
return 0
- def recover_migrate(self, deviceConfig, list, dst, step, domName):
+ def recover_migrate(self, deviceConfig, network, dst, step, domName):
""" Recover from device migration. The given step was the
last one that was successfully executed.
"""
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/python/xen/xend/server/pciif.py
--- a/tools/python/xen/xend/server/pciif.py Mon May 22 08:53:26 2006 -0600
+++ b/tools/python/xen/xend/server/pciif.py Mon May 22 14:13:38 2006 -0600
@@ -31,6 +31,7 @@ import xen.lowlevel.xc
from xen.util.pci import PciDevice
import resource
+import re
xc = xen.lowlevel.xc.xc()
@@ -106,6 +107,30 @@ class PciController(DevController):
return (0, back, {})
+ def configuration(self, devid):
+ """@see DevController.configuration"""
+
+ result = DevController.configuration(self, devid)
+
+ (num_devs) = self.readBackend(devid, 'num_devs')
+
+ for i in range(int(num_devs)):
+ (dev_config) = self.readBackend(devid, 'dev-%d'%(i))
+
+ pci_match = re.match(r"((?P<domain>[0-9a-fA-F]{1,4})[:,])?" + \
+ r"(?P<bus>[0-9a-fA-F]{1,2})[:,]" + \
+ r"(?P<slot>[0-9a-fA-F]{1,2})[.,]" + \
+ r"(?P<func>[0-9a-fA-F]{1,2})", dev_config)
+ if pci_match!=None:
+ pci_dev_info = pci_match.groupdict('0')
+ result.append( ['dev', \
+ ['domain', '0x'+pci_dev_info['domain']], \
+ ['bus', '0x'+pci_dev_info['bus']], \
+ ['slot', '0x'+pci_dev_info['slot']], \
+ ['func', '0x'+pci_dev_info['func']]])
+
+ return result
+
def setupDevice(self, domain, bus, slot, func):
""" Attach I/O resources for device to frontend domain
"""
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/python/xen/xend/server/tpmif.py
--- a/tools/python/xen/xend/server/tpmif.py Mon May 22 08:53:26 2006 -0600
+++ b/tools/python/xen/xend/server/tpmif.py Mon May 22 14:13:38 2006 -0600
@@ -71,12 +71,12 @@ class TPMifController(DevController):
return result
- def migrate(self, deviceConfig, live, dst, step, domName):
+ def migrate(self, deviceConfig, network, dst, step, domName):
"""@see DevContoller.migrate"""
- if live:
+ if network:
tool = xroot.get_external_migration_tool()
if tool != '':
- log.info("Request to live-migrate device to %s. step=%d.",
+ log.info("Request to network-migrate device to %s. step=%d.",
dst, step)
if step == DEV_MIGRATE_TEST:
@@ -99,12 +99,12 @@ class TPMifController(DevController):
return -1
return 0
- def recover_migrate(self, deviceConfig, live, dst, step, domName):
+ def recover_migrate(self, deviceConfig, network, dst, step, domName):
"""@see DevContoller.recover_migrate"""
- if live:
+ if network:
tool = xroot.get_external_migration_tool()
if tool != '':
- log.info("Request to recover live-migrated device. last good
step=%d.",
+ log.info("Request to recover network-migrated device. last
good step=%d.",
step)
fd = os.popen("%s -type vtpm -step %d -host %s -domname %s
-recover" %
(tool, step, dst, domName),
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/security/Makefile
--- a/tools/security/Makefile Mon May 22 08:53:26 2006 -0600
+++ b/tools/security/Makefile Mon May 22 14:13:38 2006 -0600
@@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk
CFLAGS += -Werror
CFLAGS += -fno-strict-aliasing
-CFLAGS += -I.
+CFLAGS += -I. -I $(XEN_LIBXC)
CPPFLAGS += -MMD -MF .$*.d
PROG_DEPS = .*.d
@@ -89,7 +89,7 @@ build: mk-symlinks $(ACM_INST_TOOLS) $(A
chmod 700 $(ACM_SCRIPTS)
xensec_tool: $(OBJS_TOOL)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -L$(XEN_LIBXC) -lxenctrl
xensec_xml2bin: $(OBJS_XML2BIN)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/security/secpol_tool.c
--- a/tools/security/secpol_tool.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/security/secpol_tool.c Mon May 22 14:13:38 2006 -0600
@@ -231,14 +231,16 @@ uint8_t pull_buffer[PULL_CACHE_SIZE];
uint8_t pull_buffer[PULL_CACHE_SIZE];
int acm_domain_getpolicy(int xc_handle)
{
- struct acm_op op;
+ struct acm_getpolicy getpolicy;
int ret;
memset(pull_buffer, 0x00, sizeof(pull_buffer));
- op.cmd = ACM_GETPOLICY;
- op.u.getpolicy.pullcache = (void *) pull_buffer;
- op.u.getpolicy.pullcache_size = sizeof(pull_buffer);
- if ((ret = xc_acm_op(xc_handle, &op)) < 0) {
+ getpolicy.interface_version = ACM_INTERFACE_VERSION;
+ getpolicy.pullcache = (void *) pull_buffer;
+ getpolicy.pullcache_size = sizeof(pull_buffer);
+ ret = xc_acm_op(xc_handle, ACMOP_getpolicy, &getpolicy, sizeof(getpolicy));
+
+ if (ret < 0) {
printf("ACM operation failed: errno=%d\n", errno);
if (errno == EACCES)
fprintf(stderr, "ACM operation failed -- need to"
@@ -275,13 +277,13 @@ int acm_domain_loadpolicy(int xc_handle,
goto free_out;
}
if (len == read(fd, buffer, len)) {
- struct acm_op op;
+ struct acm_setpolicy setpolicy;
/* dump it and then push it down into xen/acm */
acm_dump_policy_buffer(buffer, len);
- op.cmd = ACM_SETPOLICY;
- op.u.setpolicy.pushcache = (void *) buffer;
- op.u.setpolicy.pushcache_size = len;
- ret = xc_acm_op(xc_handle, &op);
+ setpolicy.interface_version = ACM_INTERFACE_VERSION;
+ setpolicy.pushcache = (void *) buffer;
+ setpolicy.pushcache_size = len;
+ ret = xc_acm_op(xc_handle, ACMOP_setpolicy, &setpolicy,
sizeof(setpolicy));
if (ret)
printf
@@ -322,15 +324,15 @@ int acm_domain_dumpstats(int xc_handle)
int acm_domain_dumpstats(int xc_handle)
{
uint8_t stats_buffer[PULL_STATS_SIZE];
- struct acm_op op;
+ struct acm_dumpstats dumpstats;
int ret;
struct acm_stats_buffer *stats;
memset(stats_buffer, 0x00, sizeof(stats_buffer));
- op.cmd = ACM_DUMPSTATS;
- op.u.dumpstats.pullcache = (void *) stats_buffer;
- op.u.dumpstats.pullcache_size = sizeof(stats_buffer);
- ret = xc_acm_op(xc_handle, &op);
+ dumpstats.interface_version = ACM_INTERFACE_VERSION;
+ dumpstats.pullcache = (void *) stats_buffer;
+ dumpstats.pullcache_size = sizeof(stats_buffer);
+ ret = xc_acm_op(xc_handle, ACMOP_dumpstats, &dumpstats, sizeof(dumpstats));
if (ret < 0) {
printf
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/tests/Makefile
--- a/tools/tests/Makefile Mon May 22 08:53:26 2006 -0600
+++ b/tools/tests/Makefile Mon May 22 14:13:38 2006 -0600
@@ -3,8 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk
include $(XEN_ROOT)/tools/Rules.mk
TARGET := test_x86_emulator
-
-HOSTCFLAGS += -D__TEST_HARNESS__
.PHONY: all
all: $(TARGET)
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/vtpm/Makefile
--- a/tools/vtpm/Makefile Mon May 22 08:53:26 2006 -0600
+++ b/tools/vtpm/Makefile Mon May 22 14:13:38 2006 -0600
@@ -21,7 +21,9 @@ build: $(TPM_EMULATOR_DIR) $(VTPM_DIR) b
.PHONY: install
install: build
- $(MAKE) -C $(TPM_EMULATOR_DIR) $@
+ if [ "$(BUILD_EMULATOR)" = "y" ]; then \
+ $(MAKE) -C $(TPM_EMULATOR_DIR) $@ ;\
+ fi
$(MAKE) -C $(VTPM_DIR) $@
.PHONY: clean
@@ -46,20 +48,21 @@ mrproper:
# Create vtpm and TPM emulator dirs
# apply patches for 1) used as dom0 tpm driver 2) used as vtpm device instance
$(TPM_EMULATOR_DIR): $(TPM_EMULATOR_TARFILE) tpm_emulator.patch
tpm_emulator-0.2b-x86_64.patch
- tar -xzf $(TPM_EMULATOR_TARFILE);
- rm -rf $(TPM_EMULATOR_DIR)
- mv tpm_emulator-0.2 $(TPM_EMULATOR_DIR);
-
- -cd $(TPM_EMULATOR_DIR); \
- patch -p1 < ../tpm_emulator-0.2b-x86_64.patch; \
- patch -p1 <../tpm_emulator.patch
+ if [ "$(BUILD_EMULATOR)" = "y" ]; then \
+ tar -xzf $(TPM_EMULATOR_TARFILE); \
+ rm -rf $(TPM_EMULATOR_DIR); \
+ mv tpm_emulator-0.2 $(TPM_EMULATOR_DIR); \
+ cd $(TPM_EMULATOR_DIR); \
+ patch -p1 < ../tpm_emulator-0.2b-x86_64.patch; \
+ patch -p1 <../tpm_emulator.patch; \
+ fi
$(VTPM_DIR): $(TPM_EMULATOR_TARFILE) tpm_emulator-0.2b-x86_64.patch vtpm.patch
tar -xzf $(TPM_EMULATOR_TARFILE);
rm -rf $(VTPM_DIR)
mv tpm_emulator-0.2 $(VTPM_DIR);
- -cd $(VTPM_DIR); \
+ cd $(VTPM_DIR); \
patch -p1 < ../tpm_emulator-0.2b-x86_64.patch; \
patch -p1 <../vtpm.patch
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/vtpm/tpm_emulator.patch
--- a/tools/vtpm/tpm_emulator.patch Mon May 22 08:53:26 2006 -0600
+++ b/tools/vtpm/tpm_emulator.patch Mon May 22 14:13:38 2006 -0600
@@ -52,7 +52,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
-KERNEL_BUILD := /lib/modules/$(KERNEL_RELEASE)/build
+CUR_DIR := $(shell pwd)
+LINUX_VERSION := $(shell cat
$(CUR_DIR)/$(XEN_ROOT)/buildconfigs/mk.linux-2.6-xen | grep "LINUX_VER" | grep
"2.6" | gawk '{ print $$3 }' )
-+KERNEL_BUILD := $(XEN_ROOT)/linux-$(LINUX_VERSION)-xen0
++KERNEL_BUILD := $(XEN_ROOT)/linux-$(LINUX_VERSION)-xen
MOD_SUBDIR := misc
COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/)
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/vtpm/vtpm.patch
--- a/tools/vtpm/vtpm.patch Mon May 22 08:53:26 2006 -0600
+++ b/tools/vtpm/vtpm.patch Mon May 22 14:13:38 2006 -0600
@@ -1,12 +1,12 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
diff -uprN orig/tpm_emulator-0.2-x86_64/AUTHORS vtpm/AUTHORS
--- orig/tpm_emulator-0.2-x86_64/AUTHORS 2005-08-15 00:58:57.000000000
-0700
-+++ vtpm/AUTHORS 2005-09-14 20:27:22.000000000 -0700
++++ vtpm/AUTHORS 2006-05-17 09:31:11.000000000 -0700
@@ -1 +1,2 @@
Mario Strasser <mast@xxxxxxx>
+INTEL Corp <>
diff -uprN orig/tpm_emulator-0.2-x86_64/ChangeLog vtpm/ChangeLog
--- orig/tpm_emulator-0.2-x86_64/ChangeLog 2005-08-15 00:58:57.000000000
-0700
-+++ vtpm/ChangeLog 2005-09-14 20:27:22.000000000 -0700
++++ vtpm/ChangeLog 2006-05-17 09:31:11.000000000 -0700
@@ -1,3 +1,7 @@
+2005-08-16 Intel Corp
+ Moved module out of kernel to run as a ring 3 app
@@ -16,8 +16,8 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
* all: some typos corrected
* tpm_integrity.c: bug in TPM_Extend fixed
diff -uprN orig/tpm_emulator-0.2-x86_64/crypto/gmp_kernel_wrapper.c
vtpm/crypto/gmp_kernel_wrapper.c
---- orig/tpm_emulator-0.2-x86_64/crypto/gmp_kernel_wrapper.c 2005-09-15
19:21:42.508873032 -0700
-+++ vtpm/crypto/gmp_kernel_wrapper.c 2005-09-15 19:25:37.319176440 -0700
+--- orig/tpm_emulator-0.2-x86_64/crypto/gmp_kernel_wrapper.c 2006-05-17
09:34:13.000000000 -0700
++++ vtpm/crypto/gmp_kernel_wrapper.c 2006-05-17 09:31:11.000000000 -0700
@@ -1,5 +1,6 @@
/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
* Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -59,10 +59,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
{
- void *ret = (void*)kmalloc(new_size, GFP_KERNEL);
- if (!ret) panic(KERN_CRIT TPM_MODULE_NAME "GMP: Cannot reallocate memory "
-- "(old_size=%Zu new_size=%Zu)\n", old_size, new_size);
+ void *ret = (void*)malloc(new_size);
+ if (!ret) error("GMP: Cannot reallocate memory "
-+ "(old_size=%Zu new_size=%Zu)\n", old_size, new_size);
+ "(old_size=%Zu new_size=%Zu)\n", old_size, new_size);
memcpy(ret, oldptr, old_size);
- kfree(oldptr);
+ free(oldptr);
@@ -80,7 +79,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
diff -uprN orig/tpm_emulator-0.2-x86_64/crypto/rsa.c vtpm/crypto/rsa.c
--- orig/tpm_emulator-0.2-x86_64/crypto/rsa.c 2005-08-15 00:58:57.000000000
-0700
-+++ vtpm/crypto/rsa.c 2005-09-14 20:27:22.000000000 -0700
++++ vtpm/crypto/rsa.c 2006-05-17 09:31:11.000000000 -0700
@@ -1,5 +1,6 @@
/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
* Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -107,7 +106,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
if (memcmp(&msg[1], &msg[1 + SHA1_DIGEST_LENGTH],
SHA1_DIGEST_LENGTH) != 0) return -1;
diff -uprN orig/tpm_emulator-0.2-x86_64/linux_module.c vtpm/linux_module.c
---- orig/tpm_emulator-0.2-x86_64/linux_module.c 2005-09-15
19:22:40.343080896 -0700
+--- orig/tpm_emulator-0.2-x86_64/linux_module.c 2006-05-17
09:34:13.000000000 -0700
+++ vtpm/linux_module.c 1969-12-31 16:00:00.000000000 -0800
@@ -1,163 +0,0 @@
-/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
@@ -274,8 +273,8 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
-}
-
diff -uprN orig/tpm_emulator-0.2-x86_64/linux_module.h vtpm/linux_module.h
---- orig/tpm_emulator-0.2-x86_64/linux_module.h 2005-09-15
19:21:14.844078720 -0700
-+++ vtpm/linux_module.h 2005-09-14 20:27:22.000000000 -0700
+--- orig/tpm_emulator-0.2-x86_64/linux_module.h 2006-05-17
09:34:13.000000000 -0700
++++ vtpm/linux_module.h 2006-05-17 09:31:11.000000000 -0700
@@ -1,5 +1,6 @@
/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
* Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -376,8 +375,8 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
#define LE16_TO_CPU(x) __le16_to_cpu(x)
diff -uprN orig/tpm_emulator-0.2-x86_64/Makefile vtpm/Makefile
---- orig/tpm_emulator-0.2-x86_64/Makefile 2005-09-15 19:21:14.845078568
-0700
-+++ vtpm/Makefile 2005-09-14 20:27:22.000000000 -0700
+--- orig/tpm_emulator-0.2-x86_64/Makefile 2006-05-17 09:34:13.000000000
-0700
++++ vtpm/Makefile 2006-05-17 09:31:11.000000000 -0700
@@ -1,22 +1,31 @@
# Software-Based Trusted Platform Module (TPM) Emulator for Linux
# Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>
@@ -410,7 +409,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
+
+CC := gcc
+CFLAGS += -g -Wall $(INCLUDE) -DDEBUG
-+CFLAGS += -I. -Itpm
++CFLAGS += -I. -Itpm -I../../vtpm_manager/manager
+
+# Is the simulator running in it's own vm?
+#CFLAGS += -DVTPM_MULTI_VM
@@ -470,8 +469,8 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
$(src)/crypto/libgmp.a:
test -f $(src)/crypto/libgmp.a || ln -s $(GMP_LIB)
$(src)/crypto/libgmp.a
diff -uprN orig/tpm_emulator-0.2-x86_64/README vtpm/README
---- orig/tpm_emulator-0.2-x86_64/README 2005-08-15 00:58:57.000000000
-0700
-+++ vtpm/README 2005-09-14 20:27:22.000000000 -0700
+--- orig/tpm_emulator-0.2-x86_64/README 2006-05-17 09:34:13.000000000
-0700
++++ vtpm/README 2006-05-17 09:31:11.000000000 -0700
@@ -13,7 +13,8 @@ $Id: README 8 2005-01-25 21:11:45Z jmoli
Copyright
--------------------------------------------------------------------------
@@ -484,7 +483,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
it under the terms of the GNU General Public License as published by
diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_audit.c vtpm/tpm/tpm_audit.c
--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_audit.c 2005-08-15
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_audit.c 2005-09-14 20:27:22.000000000 -0700
++++ vtpm/tpm/tpm_audit.c 2006-05-17 09:31:11.000000000 -0700
@@ -1,6 +1,7 @@
/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
* Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -549,7 +548,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
-
diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_authorization.c
vtpm/tpm/tpm_authorization.c
--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_authorization.c 2005-08-15
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_authorization.c 2005-09-14 20:27:22.000000000 -0700
++++ vtpm/tpm/tpm_authorization.c 2006-05-17 09:31:11.000000000 -0700
@@ -1,6 +1,7 @@
/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
* Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -575,7 +574,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
-
diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_capability.c
vtpm/tpm/tpm_capability.c
--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_capability.c 2005-08-15
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_capability.c 2005-09-14 20:27:22.000000000 -0700
++++ vtpm/tpm/tpm_capability.c 2006-05-17 09:31:11.000000000 -0700
@@ -1,6 +1,7 @@
/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
* Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -600,7 +599,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
-
diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_cmd_handler.c
vtpm/tpm/tpm_cmd_handler.c
--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_cmd_handler.c 2005-08-15
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_cmd_handler.c 2005-09-14 20:27:22.000000000 -0700
++++ vtpm/tpm/tpm_cmd_handler.c 2006-05-17 09:31:11.000000000 -0700
@@ -1,6 +1,7 @@
/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
* Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -664,8 +663,8 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
}
-
diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_crypto.c vtpm/tpm/tpm_crypto.c
---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_crypto.c 2005-09-15
19:21:14.846078416 -0700
-+++ vtpm/tpm/tpm_crypto.c 2005-09-14 20:27:22.000000000 -0700
+--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_crypto.c 2006-05-17
09:34:13.000000000 -0700
++++ vtpm/tpm/tpm_crypto.c 2006-05-17 09:31:11.000000000 -0700
@@ -1,6 +1,7 @@
/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
* Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -689,8 +688,8 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
}
-
diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_data.c vtpm/tpm/tpm_data.c
---- orig/tpm_emulator-0.2-x86_64/tpm/tpm_data.c 2005-09-15
19:21:14.847078264 -0700
-+++ vtpm/tpm/tpm_data.c 2005-09-14 20:27:22.000000000 -0700
+--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_data.c 2006-05-17
09:34:13.000000000 -0700
++++ vtpm/tpm/tpm_data.c 2006-05-17 09:31:11.000000000 -0700
@@ -1,6 +1,7 @@
/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
* Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -760,8 +759,8 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
+#ifdef VTPM_MUTLI_VM
+ #define DEV_FE "/dev/tpm"
+#else
-+ #define VTPM_RX_FIFO_D "/var/vtpm/fifos/vtpm-to-%d.fifo"
-+ #define VTPM_TX_FIFO "/var/vtpm/fifos/vtpm-from-all.fifo"
++ #define VTPM_RX_FIFO_D "/var/vtpm/fifos/vtpm_rsp_to_%d.fifo"
++ #define VTPM_TX_FIFO "/var/vtpm/fifos/vtpm_cmd_from_all.fifo"
+
+ extern int dmi_id;
+ static char *vtpm_rx_name=NULL;
@@ -1021,7 +1020,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
-
diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_deprecated.c
vtpm/tpm/tpm_deprecated.c
--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_deprecated.c 2005-08-15
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_deprecated.c 2005-09-14 20:27:22.000000000 -0700
++++ vtpm/tpm/tpm_deprecated.c 2006-05-17 09:31:11.000000000 -0700
@@ -1,6 +1,7 @@
/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
* Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -1050,7 +1049,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
len = *authContextSize;
diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_emulator.h
vtpm/tpm/tpm_emulator.h
--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_emulator.h 2005-08-15
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_emulator.h 2005-09-14 20:27:22.000000000 -0700
++++ vtpm/tpm/tpm_emulator.h 2006-05-17 09:31:11.000000000 -0700
@@ -1,5 +1,6 @@
/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
* Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -1070,7 +1069,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
* tpm_emulator_init - initialises and starts the TPM emulator
diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_integrity.c
vtpm/tpm/tpm_integrity.c
--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_integrity.c 2005-08-15
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_integrity.c 2005-09-14 20:27:22.000000000 -0700
++++ vtpm/tpm/tpm_integrity.c 2006-05-17 09:31:11.000000000 -0700
@@ -1,6 +1,7 @@
/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
* Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -1086,7 +1085,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
-
diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_structures.h
vtpm/tpm/tpm_structures.h
--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_structures.h 2005-08-15
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_structures.h 2005-09-14 20:27:22.000000000 -0700
++++ vtpm/tpm/tpm_structures.h 2006-05-17 09:31:11.000000000 -0700
@@ -1,6 +1,7 @@
/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
* Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -1106,7 +1105,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
/*
diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_testing.c
vtpm/tpm/tpm_testing.c
--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_testing.c 2005-08-15
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_testing.c 2005-09-14 20:27:22.000000000 -0700
++++ vtpm/tpm/tpm_testing.c 2006-05-17 09:31:11.000000000 -0700
@@ -1,6 +1,7 @@
/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
* Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -1224,7 +1223,7 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/tpm_ticks.c vtpm/tpm/tpm_ticks.c
--- orig/tpm_emulator-0.2-x86_64/tpm/tpm_ticks.c 2005-08-15
00:58:57.000000000 -0700
-+++ vtpm/tpm/tpm_ticks.c 2005-09-14 20:27:22.000000000 -0700
++++ vtpm/tpm/tpm_ticks.c 2006-05-17 09:31:11.000000000 -0700
@@ -1,6 +1,7 @@
/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
* Copyright (C) 2004 Mario Strasser <mast@xxxxxxx>,
@@ -1307,139 +1306,9 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
}
-diff -uprN orig/tpm_emulator-0.2-x86_64/tpm/vtpm_manager.h
vtpm/tpm/vtpm_manager.h
---- orig/tpm_emulator-0.2-x86_64/tpm/vtpm_manager.h 1969-12-31
16:00:00.000000000 -0800
-+++ vtpm/tpm/vtpm_manager.h 2005-09-14 20:27:22.000000000 -0700
-@@ -0,0 +1,126 @@
-+// ===================================================================
-+//
-+// Copyright (c) 2005, Intel Corp.
-+// All rights reserved.
-+//
-+// Redistribution and use in source and binary forms, with or without
-+// modification, are permitted provided that the following conditions
-+// are met:
-+//
-+// * Redistributions of source code must retain the above copyright
-+// notice, this list of conditions and the following disclaimer.
-+// * Redistributions in binary form must reproduce the above
-+// copyright notice, this list of conditions and the following
-+// disclaimer in the documentation and/or other materials provided
-+// with the distribution.
-+// * Neither the name of Intel Corporation nor the names of its
-+// contributors may be used to endorse or promote products derived
-+// from this software without specific prior written permission.
-+//
-+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-+// OF THE POSSIBILITY OF SUCH DAMAGE.
-+// ===================================================================
-+//
-+// vtpm_manager.h
-+//
-+// Public Interface header for VTPM Manager
-+//
-+// ==================================================================
-+
-+#ifndef __VTPM_MANAGER_H__
-+#define __VTPM_MANAGER_H__
-+
-+#define VTPM_TAG_REQ 0x01c1
-+#define VTPM_TAG_RSP 0x01c4
-+#define COMMAND_BUFFER_SIZE 4096
-+
-+// Header sizes. Note Header MAY include the DMI
-+#define VTPM_COMMAND_HEADER_SIZE_SRV ( sizeof(UINT32) + sizeof(TPM_TAG) +
sizeof(UINT32) + sizeof(TPM_COMMAND_CODE))
-+#define VTPM_COMMAND_HEADER_SIZE_CLT ( sizeof(TPM_TAG) +
sizeof(UINT32) + sizeof(TPM_COMMAND_CODE))
-+
-+//************************ Command Codes ****************************
-+#define VTPM_ORD_OPEN 1 // ULM Creates New DMI
-+#define VTPM_ORD_CLOSE 2 // ULM Closes a DMI
-+#define VTPM_ORD_DELETE 3 // ULM Permemently Deletes DMI
-+#define VTPM_ORD_SAVENVM 4 // DMI requests Secrets Unseal
-+#define VTPM_ORD_LOADNVM 5 // DMI requests Secrets Saved
-+#define VTPM_ORD_TPMCOMMAND 6 // DMI issues HW TPM Command
-+
-+//************************ Return Codes ****************************
-+#define VTPM_SUCCESS 0
-+#define VTPM_FAIL 1
-+#define VTPM_UNSUPPORTED 2
-+#define VTPM_FORBIDDEN 3
-+#define VTPM_RESTORE_CONTEXT_FAILED 4
-+#define VTPM_INVALID_REQUEST 5
-+
-+/******************* Command Parameter API *************************
-+
-+VTPM Command Format
-+ dmi: 4 bytes // Source of message.
-+ // WARNING: This is prepended by the channel.
-+ // Thus it is received by VTPM Manager,
-+ // but not sent by DMI
-+ tpm tag: 2 bytes
-+ command size: 4 bytes // Size of command including header but not
DMI
-+ ord: 4 bytes // Command ordinal above
-+ parameters: size - 10 bytes // Command Parameter
-+
-+VTPM Response Format
-+ tpm tag: 2 bytes
-+ response_size: 4 bytes
-+ status: 4 bytes
-+ parameters: size - 10 bytes
-+
-+
-+VTPM_Open:
-+ Input Parameters:
-+ Domain_type: 1 byte
-+ domain_id: 4 bytes
-+ instance_id: 4 bytes
-+ Output Parameters:
-+ None
-+
-+VTPM_Close
-+ Input Parameters:
-+ instance_id: 4 bytes
-+ Output Parameters:
-+ None
-+
-+VTPM_Delete
-+ Input Parameters:
-+ instance_id: 4 bytes
-+ Output Parameters:
-+ None
-+
-+VTPM_SaveNVM
-+ Input Parameters:
-+ data: n bytes (Header indicates size of data)
-+ Output Parameters:
-+ None
-+
-+VTPM_LoadNVM
-+ Input Parameters:
-+ None
-+ Output Parameters:
-+ data: n bytes (Header indicates size of data)
-+
-+VTPM_TPMCommand
-+ Input Parameters:
-+ TPM Command Byte Stream: n bytes
-+ Output Parameters:
-+ TPM Reponse Byte Stream: n bytes
-+
-+*********************************************************************/
-+
-+#endif //_VTPM_MANAGER_H_
diff -uprN orig/tpm_emulator-0.2-x86_64/tpmd.c vtpm/tpmd.c
--- orig/tpm_emulator-0.2-x86_64/tpmd.c 1969-12-31 16:00:00.000000000
-0800
-+++ vtpm/tpmd.c 2005-09-15 19:28:55.783005352 -0700
++++ vtpm/tpmd.c 2006-05-17 09:31:11.000000000 -0700
@@ -0,0 +1,207 @@
+/* Software-Based Trusted Platform Module (TPM) Emulator for Linux
+ * Copyright (C) 2005 INTEL Corp
@@ -1471,8 +1340,8 @@ diff -uprN orig/tpm_emulator-0.2-x86_64/
+#ifdef VTPM_MULTI_VM
+ #define DEV_BE "/dev/vtpm"
+#else
-+ #define GUEST_RX_FIFO_D "/var/vtpm/fifos/guest-to-%d.fifo"
-+ #define GUEST_TX_FIFO "/var/vtpm/fifos/guest-from-all.fifo"
++ #define GUEST_RX_FIFO_D "/var/vtpm/fifos/tpm_cmd_to_%d.fifo"
++ #define GUEST_TX_FIFO "/var/vtpm/fifos/tpm_rsp_from_all.fifo"
+#endif
+
+ int dmi_id;
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/vtpm_manager/Rules.mk
--- a/tools/vtpm_manager/Rules.mk Mon May 22 08:53:26 2006 -0600
+++ b/tools/vtpm_manager/Rules.mk Mon May 22 14:13:38 2006 -0600
@@ -40,6 +40,9 @@ OBJS = $(patsubst %.c,%.o,$(SRCS))
# Project-specific definitions
#
+# Need UNIX98 spec for pthread rwlocks
+CFLAGS += -D_GNU_SOURCE
+
# Logging Level. See utils/tools.h for usage
CFLAGS +=
-DLOGGING_MODULES="(BITMASK(VTPM_LOG_TCS)|BITMASK(VTPM_LOG_VTSP)|BITMASK(VTPM_LOG_VTPM)|BITMASK(VTPM_LOG_VTPM_DEEP))"
@@ -50,7 +53,7 @@ CFLAGS += -DLOGGING_MODULES="(BITMASK(VT
# Use frontend/backend pairs between manager & DMs?
#CFLAGS += -DVTPM_MULTI_VM
-# vtpm_manager listens on /tmp/in.fifo and /tmp/out.fifo rather than backend
+# vtpm_manager listens on fifo's rather than backend
#CFLAGS += -DDUMMY_BACKEND
# Do not have manager launch DMs.
@@ -59,9 +62,6 @@ CFLAGS += -DLOGGING_MODULES="(BITMASK(VT
# Fixed OwnerAuth
#CFLAGS += -DWELL_KNOWN_OWNER_AUTH
-# TPM Hardware Device or TPM Simulator
-#CFLAGS += -DTPM_HWDEV
-
# Include
CFLAGS += -I$(XEN_ROOT)/tools/vtpm_manager/crypto
CFLAGS += -I$(XEN_ROOT)/tools/vtpm_manager/util
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/vtpm_manager/manager/dmictl.c
--- a/tools/vtpm_manager/manager/dmictl.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/vtpm_manager/manager/dmictl.c Mon May 22 14:13:38 2006 -0600
@@ -55,66 +55,30 @@
#include "log.h"
#include "hashtable.h"
#include "hashtable_itr.h"
+#include "vtpm_ipc.h"
#define TPM_EMULATOR_PATH "/usr/bin/vtpmd"
-TPM_RESULT close_dmi( VTPM_DMI_RESOURCE *dmi_res) {
- TPM_RESULT status = TPM_FAIL;
-
+TPM_RESULT close_dmi(VTPM_DMI_RESOURCE *dmi_res) {
if (dmi_res == NULL)
return TPM_SUCCESS;
- status = TCS_CloseContext(dmi_res->TCSContext);
+ TCS_CloseContext(dmi_res->TCSContext);
free ( dmi_res->NVMLocation );
dmi_res->connected = FALSE;
-#ifndef VTPM_MULTI_VM
- free(dmi_res->guest_tx_fname);
- free(dmi_res->vtpm_tx_fname);
-
- close(dmi_res->guest_tx_fh); dmi_res->guest_tx_fh = -1;
- close(dmi_res->vtpm_tx_fh); dmi_res->vtpm_tx_fh = -1;
vtpm_globals->connected_dmis--;
- if (vtpm_globals->connected_dmis == 0) {
- // No more DMI's connected. Close fifo to prevent a broken pipe.
- close(vtpm_globals->guest_rx_fh);
- vtpm_globals->guest_rx_fh = -1;
- }
- #ifndef MANUAL_DM_LAUNCH
- if (dmi_res->dmi_id != VTPM_CTL_DM) {
- if (dmi_res->dmi_pid != 0) {
- vtpmloginfo(VTPM_LOG_VTPM, "Killing dmi on pid %d.\n", dmi_res->dmi_pid);
- if (kill(dmi_res->dmi_pid, SIGKILL) !=0) {
- vtpmloginfo(VTPM_LOG_VTPM, "DMI on pid %d is already dead.\n",
dmi_res->dmi_pid);
- } else if (waitpid(dmi_res->dmi_pid, NULL, 0) != dmi_res->dmi_pid) {
- vtpmlogerror(VTPM_LOG_VTPM, "DMI on pid %d failed to stop.\n",
dmi_res->dmi_pid);
- status = TPM_FAIL;
- }
- } else {
- vtpmlogerror(VTPM_LOG_VTPM, "Could not kill dmi because it's pid was
0.\n");
- status = TPM_FAIL;
- }
- }
- #endif
-#endif
-
- return status;
-}
-
-TPM_RESULT VTPM_Handle_New_DMI( const buffer_t *param_buf) {
+ return (VTPM_Close_DMI_Extra(dmi_res) );
+}
+
+TPM_RESULT VTPM_Handle_New_DMI(const buffer_t *param_buf) {
VTPM_DMI_RESOURCE *new_dmi=NULL;
TPM_RESULT status=TPM_FAIL;
BYTE type;
UINT32 dmi_id, domain_id, *dmi_id_key;
-#ifndef VTPM_MULTI_VM
- int fh;
- char dmi_id_str[11]; // UINT32s are up to 10 digits + NULL
- struct stat file_info;
-#endif
-
if (param_buf == NULL) { // Assume creation of Dom 0 control
type = 0;
domain_id = VTPM_CTL_DM;
@@ -156,7 +120,7 @@ TPM_RESULT VTPM_Handle_New_DMI( const bu
status = TPM_FAIL;
goto egress;
}
-
+
} else
vtpmloginfo(VTPM_LOG_VTPM, "Re-attaching DMI instance %d on domain %d
.\n", dmi_id, domain_id);
@@ -176,94 +140,16 @@ TPM_RESULT VTPM_Handle_New_DMI( const bu
new_dmi->NVMLocation = (char *) malloc(11 + strlen(DMI_NVM_FILE));
sprintf(new_dmi->NVMLocation, DMI_NVM_FILE, (uint32_t) new_dmi->dmi_id);
- // Measure DMI
- // FIXME: This will measure DMI. Until then use a fixed DMI_Measurement value
- /*
- fh = open(TPM_EMULATOR_PATH, O_RDONLY);
- stat_ret = fstat(fh, &file_stat);
- if (stat_ret == 0)
- dmi_size = file_stat.st_size;
- else {
- vtpmlogerror(VTPM_LOG_VTPM, "Could not open tpm_emulator!!\n");
- status = TPM_IOERROR;
- goto abort_egress;
- }
- dmi_buffer
- */
- memset(&new_dmi->DMI_measurement, 0xcc, sizeof(TPM_DIGEST));
-
-#ifndef VTPM_MULTI_VM
- if (dmi_id != VTPM_CTL_DM) {
- // Create a pair of fifo pipes
- if( (new_dmi->guest_tx_fname = (char *) malloc(11 +
strlen(GUEST_TX_FIFO))) == NULL){
- status = TPM_RESOURCES;
- goto abort_egress;
- }
- sprintf(new_dmi->guest_tx_fname, GUEST_TX_FIFO, (uint32_t) dmi_id);
-
- if ((new_dmi->vtpm_tx_fname = (char *) malloc(11 + strlen(VTPM_TX_FIFO)))
== NULL) {
- status = TPM_RESOURCES;
- goto abort_egress;
- }
- sprintf(new_dmi->vtpm_tx_fname, VTPM_TX_FIFO, (uint32_t) dmi_id);
-
- new_dmi->guest_tx_fh = -1;
- new_dmi->vtpm_tx_fh= -1;
-
- if ( stat(new_dmi->guest_tx_fname, &file_info) == -1) {
- if ( mkfifo(new_dmi->guest_tx_fname, S_IWUSR | S_IRUSR ) ){
- vtpmlogerror(VTPM_LOG_VTPM, "Failed to create dmi fifo.\n");
- status = TPM_IOERROR;
- goto abort_egress;
- }
- }
-
- if ( (fh = open(new_dmi->vtpm_tx_fname, O_RDWR)) == -1) {
- if ( mkfifo(new_dmi->vtpm_tx_fname, S_IWUSR | S_IRUSR ) ) {
- vtpmlogerror(VTPM_LOG_VTPM, "Failed to create dmi fifo.\n");
- status = TPM_IOERROR;
- goto abort_egress;
- }
- }
-
- // Launch DMI
- sprintf(dmi_id_str, "%d", (int) dmi_id);
-#ifdef MANUAL_DM_LAUNCH
- vtpmlogerror(VTPM_LOG_VTPM, "FAKING starting vtpm with dmi=%s\n",
dmi_id_str);
- new_dmi->dmi_pid = 0;
-#else
- pid_t pid = fork();
-
- if (pid == -1) {
- vtpmlogerror(VTPM_LOG_VTPM, "Could not fork to launch vtpm\n");
- status = TPM_RESOURCES;
- goto abort_egress;
- } else if (pid == 0) {
- if ( stat(new_dmi->NVMLocation, &file_info) == -1)
- execl (TPM_EMULATOR_PATH, "vtmpd", "clear", dmi_id_str, NULL);
- else
- execl (TPM_EMULATOR_PATH, "vtpmd", "save", dmi_id_str, NULL);
-
- // Returning from these at all is an error.
- vtpmlogerror(VTPM_LOG_VTPM, "Could not exec to launch vtpm\n");
- } else {
- new_dmi->dmi_pid = pid;
- vtpmloginfo(VTPM_LOG_VTPM, "Launching DMI on PID = %d\n", pid);
- }
-#endif // MANUAL_DM_LAUNCH
- }
-#else // VTPM_MUTLI_VM
- // FIXME: Measure DMI through call to Measurement agent in platform.
-#endif
-
- vtpm_globals->DMI_table_dirty = TRUE;
new_dmi->connected = TRUE;
- status=TPM_SUCCESS;
+
+ // Design specific new DMI code.
+ // Includes: create IPCs, Measuring DMI, and maybe launching DMI
+ status = VTPM_New_DMI_Extra(new_dmi);
goto egress;
abort_egress:
vtpmlogerror(VTPM_LOG_VTPM, "Failed to create DMI id=%d due to status=%s.
Cleaning.\n", dmi_id, tpm_get_error_name(status));
- close_dmi( new_dmi );
+ close_dmi(new_dmi );
egress:
return status;
@@ -293,7 +179,7 @@ TPM_RESULT VTPM_Handle_Close_DMI( const
goto abort_egress;
}
- if (!dmi_res->connected) {
+ if (!dmi_res->connected) {
vtpmlogerror(VTPM_LOG_VTPM, "Closing non-connected DMI.\n");
status = TPM_BAD_PARAMETER;
goto abort_egress;
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/vtpm_manager/manager/securestorage.c
--- a/tools/vtpm_manager/manager/securestorage.c Mon May 22 08:53:26
2006 -0600
+++ b/tools/vtpm_manager/manager/securestorage.c Mon May 22 14:13:38
2006 -0600
@@ -197,9 +197,6 @@ TPM_RESULT VTPM_Handle_Save_NVM(VTPM_DMI
&vtpm_globals->storageKey,
&sealed_NVM) );
- // Mark DMI Table so new save state info will get pushed to disk on return.
- vtpm_globals->DMI_table_dirty = TRUE;
-
// Write sealed blob off disk from NVMLocation
// TODO: How to properly return from these. Do we care if we return failure
// after writing the file? We can't get the old one back.
@@ -303,7 +300,7 @@ TPM_RESULT VTPM_Handle_Load_NVM(VTPM_DMI
}
-TPM_RESULT VTPM_SaveService(void) {
+TPM_RESULT VTPM_SaveManagerData(void) {
TPM_RESULT status=TPM_SUCCESS;
int fh, dmis=-1;
@@ -317,7 +314,7 @@ TPM_RESULT VTPM_SaveService(void) {
struct hashtable_itr *dmi_itr;
VTPM_DMI_RESOURCE *dmi_res;
- UINT32 boot_key_size, flat_dmis_size;
+ UINT32 boot_key_size = 0, flat_dmis_size = 0;
// Initially fill these with buffer sizes for each data type. Later fill
// in actual size, once flattened.
@@ -347,11 +344,11 @@ TPM_RESULT VTPM_SaveService(void) {
BSG_PackConst(buffer_len(&enc_flat_global), 4, flat_enc);
// Per DMI values to be saved (if any exit)
- if (hashtable_count(vtpm_globals->dmi_map) > 0) {
-
- flat_dmis_size = (hashtable_count(vtpm_globals->dmi_map) - 1) * // num
DMIS (-1 for Dom0)
- (sizeof(UINT32) + 2*sizeof(TPM_DIGEST)); // Per DMI info
- flat_dmis = (BYTE *) malloc( flat_dmis_size );
+ if (hashtable_count(vtpm_globals->dmi_map) > 1) {
+
+ flat_dmis = (BYTE *) malloc(
+ (hashtable_count(vtpm_globals->dmi_map) - 1) * // num
DMIS (-1 for Dom0)
+ (sizeof(UINT32) + 2*sizeof(TPM_DIGEST)) ); // Per DMI info
dmi_itr = hashtable_iterator(vtpm_globals->dmi_map);
do {
@@ -387,8 +384,6 @@ TPM_RESULT VTPM_SaveService(void) {
goto abort_egress;
}
- vtpm_globals->DMI_table_dirty = FALSE;
-
goto egress;
abort_egress:
@@ -400,11 +395,11 @@ TPM_RESULT VTPM_SaveService(void) {
free(flat_dmis);
close(fh);
- vtpmloginfo(VTPM_LOG_VTPM, "Saved VTPM Service state (status = %d, dmis =
%d)\n", (int) status, dmis);
- return status;
-}
-
-TPM_RESULT VTPM_LoadService(void) {
+ vtpmloginfo(VTPM_LOG_VTPM, "Saved VTPM Manager state (status = %d, dmis =
%d)\n", (int) status, dmis);
+ return status;
+}
+
+TPM_RESULT VTPM_LoadManagerData(void) {
TPM_RESULT status=TPM_SUCCESS;
int fh, stat_ret, dmis=0;
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/vtpm_manager/manager/vtpm_manager.c
--- a/tools/vtpm_manager/manager/vtpm_manager.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/vtpm_manager/manager/vtpm_manager.c Mon May 22 14:13:38 2006 -0600
@@ -39,17 +39,7 @@
#include <stdio.h>
#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include <string.h>
-
-#ifndef VTPM_MULTI_VM
-#include <pthread.h>
-#include <errno.h>
-#include <aio.h>
-#include <time.h>
-#endif
#include "vtpm_manager.h"
#include "vtpmpriv.h"
@@ -63,16 +53,6 @@
VTPM_GLOBALS *vtpm_globals=NULL;
-#ifdef VTPM_MULTI_VM
- #define vtpmhandlerloginfo(module,fmt,args...) vtpmloginfo (module, fmt,
##args );
- #define vtpmhandlerloginfomore(module,fmt,args...) vtpmloginfomore (module,
fmt, ##args );
- #define vtpmhandlerlogerror(module,fmt,args...) vtpmlogerror (module, fmt,
##args );
-#else
- #define vtpmhandlerloginfo(module,fmt,args...) vtpmloginfo (module, "[%d]: "
fmt, threadType, ##args );
- #define vtpmhandlerloginfomore(module,fmt,args...) vtpmloginfomore (module,
fmt, ##args );
- #define vtpmhandlerlogerror(module,fmt,args...) vtpmlogerror (module, "[%d]:
" fmt, threadType, ##args );
-#endif
-
// --------------------------- Well Known Auths --------------------------
const TPM_AUTHDATA SRK_AUTH = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff};
@@ -95,7 +75,7 @@ static int equals32(void *k1, void *k2)
// --------------------------- Functions ------------------------------
-TPM_RESULT VTPM_Create_Service(){
+TPM_RESULT VTPM_Create_Manager(){
TPM_RESULT status = TPM_SUCCESS;
@@ -184,562 +164,21 @@ TPM_RESULT VTPM_Create_Service(){
NULL,
&vtpm_globals->bootKey,
TRUE ) );
+
+ printf("***************************** FIXME: SAVE NEW STATE *******\n");
goto egress;
abort_egress:
exit(1);
egress:
- vtpmloginfo(VTPM_LOG_VTPM, "Finished initialized new VTPM service (Status =
%d).\n", status);
+ vtpmloginfo(VTPM_LOG_VTPM, "Finished initialized new VTPM manager (Status =
%d).\n", status);
return status;
}
-
-//////////////////////////////////////////////////////////////////////////////
-#ifdef VTPM_MULTI_VM
-int VTPM_Service_Handler(){
-#else
-void *VTPM_Service_Handler(void *threadTypePtr){
-#endif
- TPM_RESULT status = TPM_FAIL; // Should never return
- UINT32 dmi, in_param_size, cmd_size, out_param_size,
out_message_size, out_message_size_full;
- BYTE *cmd_header, *in_param, *out_message;
- buffer_t *command_buf=NULL, *result_buf=NULL;
- TPM_TAG tag;
- TPM_COMMAND_CODE ord;
- VTPM_DMI_RESOURCE *dmi_res;
- int size_read, size_write, i;
-
-#ifndef VTPM_MULTI_VM
- UINT32 dmi_cmd_size;
- BYTE *dmi_cmd;
- int threadType = *(int *) threadTypePtr;
-
- // async io structures
- struct aiocb dmi_aio;
- struct aiocb *dmi_aio_a[1];
- dmi_aio_a[0] = &dmi_aio;
-#endif
-
-#ifdef DUMMY_BACKEND
- int dummy_rx;
-#endif
-
- cmd_header = (BYTE *) malloc(VTPM_COMMAND_HEADER_SIZE_SRV);
- command_buf = (buffer_t *) malloc(sizeof(buffer_t));
- result_buf = (buffer_t *) malloc(sizeof(buffer_t));
-
-#ifndef VTPM_MULTI_VM
- TPM_RESULT *ret_value = (TPM_RESULT *) malloc(sizeof(TPM_RESULT));
-#endif
-
- int *tx_fh, // Pointer to the filehandle this function will write to
- *rx_fh; // Pointer to the filehandle this function will read from
- // For a multi VM VTPM system, this function tx/rx with the BE
- // via vtpm_globals->be_fh.
- // For a single VM system, the BE_LISTENER_THREAD tx/rx with
theBE
- // via vtpm_globals->be_fh, and the DMI_LISTENER_THREAD rx from
- // vtpm_globals->vtpm_rx_fh and tx to dmi_res->vtpm_tx_fh
-
- // Set rx_fh to point to the correct fh based on this mode.
-#ifdef VTPM_MULTI_VM
- rx_fh = &vtpm_globals->be_fh;
-#else
- if (threadType == BE_LISTENER_THREAD) {
- #ifdef DUMMY_BACKEND
- dummy_rx = -1;
- rx_fh = &dummy_rx;
- #else
- rx_fh = &vtpm_globals->be_fh;
- #endif
- } else { // DMI_LISTENER_THREAD
- rx_fh = &vtpm_globals->vtpm_rx_fh;
- }
-#endif
-
- // Set tx_fh to point to the correct fh based on this mode (If static)
- // Create any fifos that these fh will use.
-#ifndef VTPM_MULTI_VM
- int fh;
- if (threadType == BE_LISTENER_THREAD) {
- tx_fh = &vtpm_globals->be_fh;
- if ( (fh = open(GUEST_RX_FIFO, O_RDWR)) == -1) {
- if ( mkfifo(GUEST_RX_FIFO, S_IWUSR | S_IRUSR ) ){
- vtpmlogerror(VTPM_LOG_VTPM, "Unable to create FIFO: %s.\n",
GUEST_RX_FIFO);
- *ret_value = TPM_FAIL;
- pthread_exit(ret_value);
- }
- } else
- close(fh);
-
- } else { // else DMI_LISTENER_THREAD
- // tx_fh will be set once the DMI is identified
- // But we need to make sure the read pip is created.
- if ( (fh = open(VTPM_RX_FIFO, O_RDWR)) == -1) {
- if ( mkfifo(VTPM_RX_FIFO, S_IWUSR | S_IRUSR ) ){
- vtpmlogerror(VTPM_LOG_VTPM, "Unable to create FIFO: %s.\n",
VTPM_RX_FIFO);
- *ret_value = TPM_FAIL;
- pthread_exit(ret_value);
- }
- } else
- close(fh);
-
- }
-#else
- tx_fh = &vtpm_globals->be_fh;
-#endif
-
- ////////////////////////// Main Loop //////////////////////////////////
- while(1) {
-
-#ifdef VTPM_MULTI_VM
- vtpmhandlerloginfo(VTPM_LOG_VTPM, "Waiting for DMI messages.\n");
-#else
- if (threadType == BE_LISTENER_THREAD) {
- vtpmhandlerloginfo(VTPM_LOG_VTPM, "Waiting for Guest requests & ctrl
messages.\n");
- } else
- vtpmhandlerloginfo(VTPM_LOG_VTPM, "Waiting for DMI messages.\n");
-#endif
-
- // Check status of rx_fh. If necessary attempt to re-open it.
- char* s = NULL;
- if (*rx_fh < 0) {
-#ifdef VTPM_MULTI_VM
- s = VTPM_BE_DEV;
-#else
- if (threadType == BE_LISTENER_THREAD)
- #ifdef DUMMY_BACKEND
- s = "/tmp/in.fifo";
- #else
- s = VTPM_BE_DEV;
- #endif
- else // DMI Listener
- s = VTPM_RX_FIFO;
- *rx_fh = open(s, O_RDWR);
-#endif
- }
-
- // Respond to failures to open rx_fh
- if (*rx_fh < 0) {
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Can't open inbound fh for %s.\n", s);
-#ifdef VTPM_MULTI_VM
- return TPM_IOERROR;
-#else
- *ret_value = TPM_IOERROR;
- pthread_exit(ret_value);
-#endif
- }
-
- // Read command header from rx_fh
- size_read = read(*rx_fh, cmd_header, VTPM_COMMAND_HEADER_SIZE_SRV);
- if (size_read > 0) {
- vtpmhandlerloginfo(VTPM_LOG_VTPM_DEEP, "RECV[%d}: 0x", size_read);
- for (i=0; i<size_read; i++)
- vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "%x ",
cmd_header[i]);
- } else {
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Can't read from BE. Aborting... \n");
- close(*rx_fh);
- *rx_fh = -1;
- goto abort_command;
- }
-
- if (size_read < (int) VTPM_COMMAND_HEADER_SIZE_SRV) {
- vtpmhandlerloginfo(VTPM_LOG_VTPM_DEEP, "\n");
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Command shorter than normal header
(%d bytes). Aborting...\n", size_read);
- goto abort_command;
- }
-
- // Unpack header
- BSG_UnpackList(cmd_header, 4,
- BSG_TYPE_UINT32, &dmi,
- BSG_TPM_TAG, &tag,
- BSG_TYPE_UINT32, &in_param_size,
- BSG_TPM_COMMAND_CODE, &ord );
-
- // Using the header info, read from rx_fh the parameters of the command
- // Note that in_param_size is in the client's context
- cmd_size = in_param_size - VTPM_COMMAND_HEADER_SIZE_CLT;
- if (cmd_size > 0) {
- in_param = (BYTE *) malloc(cmd_size);
- size_read = read( *rx_fh, in_param, cmd_size);
- if (size_read > 0) {
- for (i=0; i<size_read; i++)
- vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "%x ", in_param[i]);
-
- } else {
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Error reading from cmd.
Aborting... \n");
- close(*rx_fh);
- *rx_fh = -1;
- goto abort_command;
- }
- vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "\n");
-
- if (size_read < (int) cmd_size) {
- vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "\n");
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Command read(%d) is shorter than
header indicates(%d). Aborting...\n", size_read, cmd_size);
- goto abort_command;
- }
- } else {
- in_param = NULL;
- vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "\n");
- }
-
-#ifndef VTPM_MULTI_VM
- // It's illegal to receive a Dom0 command from a DMI.
- if ((threadType != BE_LISTENER_THREAD) && (dmi == 0)) {
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Attempt to access dom0 commands from
DMI interface. Aborting...\n");
- goto abort_command;
- }
-#endif
-
- // Fetch infomation about the DMI issuing the request.
- dmi_res = (VTPM_DMI_RESOURCE *) hashtable_search(vtpm_globals->dmi_map,
&dmi);
- if (dmi_res == NULL) {
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Attempted access to non-existent DMI
in domain: %d. Aborting...\n", dmi);
- goto abort_command;
- }
- if (!dmi_res->connected) {
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Attempted access to disconnected DMI
in domain: %d. Aborting...\n", dmi);
- goto abort_command;
- }
-
-#ifndef VTPM_MULTI_VM
- // Now that we know which DMI this is, we can set the tx_fh handle.
- if (threadType != BE_LISTENER_THREAD)
- tx_fh = &dmi_res->vtpm_tx_fh;
- // else we set this before the while loop since it doesn't change.
-#endif
-
- // Init the buffers used to handle the command and the response
- if ( (buffer_init_convert(command_buf, cmd_size, in_param) != TPM_SUCCESS)
||
- (buffer_init(result_buf, 0, 0) != TPM_SUCCESS) ) {
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Failed to setup buffers.
Aborting...\n");
- goto abort_command;
- }
-
- // Dispatch it as either control or user request.
- if (tag == VTPM_TAG_REQ) {
- if (dmi_res->dmi_id == VTPM_CTL_DM){
- switch (ord) {
- case VTPM_ORD_OPEN:
- status = VTPM_Handle_New_DMI(command_buf);
- break;
-
- case VTPM_ORD_CLOSE:
- status = VTPM_Handle_Close_DMI(command_buf);
- break;
-
- case VTPM_ORD_DELETE:
- status = VTPM_Handle_Delete_DMI(command_buf);
- break;
- default:
- status = TPM_BAD_ORDINAL;
- } // switch
- } else {
-
- switch (ord) {
- case VTPM_ORD_SAVENVM:
- status= VTPM_Handle_Save_NVM(dmi_res,
- command_buf,
- result_buf);
- break;
- case VTPM_ORD_LOADNVM:
- status= VTPM_Handle_Load_NVM(dmi_res,
- command_buf,
- result_buf);
- break;
-
- case VTPM_ORD_TPMCOMMAND:
- status= VTPM_Handle_TPM_Command(dmi_res,
- command_buf,
- result_buf);
- break;
-
- default:
- status = TPM_BAD_ORDINAL;
- } // switch
- }
- } else { // This is not a VTPM Command at all.
- // This happens in two cases.
- // MULTI_VM = A DMI illegally sent a raw TPM command to the manager
- // Single VM:
- // BE_LISTENER_THREAD: Guest issued a TPM command.
- // Send this to DMI and wait for response
- // DMI_LISTENER_THREAD: A DMI illegally sent a raw TPM command.
-
-#ifdef VTPM_MULTI_VM
- // Raw TPM commands are not supported from the DMI
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Attempt to use unsupported direct
access to TPM.\n");
- vtpmhandlerloginfo(VTPM_LOG_VTPM_DEEP, "Bad Command. dmi:%d, tag:%d,
size:%d, ord:%d, Params: ", dmi, tag, in_param_size, ord);
- for (i=0; i<cmd_size; i++)
- vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "%x ", in_param[i]);
-
- vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "\n");
- status = TPM_FAIL;
-
-#else
- // If BE_LISTENER_THREAD then this is a TPM command from a guest
- if (threadType == BE_LISTENER_THREAD) {
- // Dom0 can't talk to the BE, so this must be a broken FE/BE or badness
- if (dmi == 0) {
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Illegal use of TPM command from
dom0\n");
- status = TPM_FAIL;
- } else {
- vtpmhandlerloginfo(VTPM_LOG_VTPM, "Forwarding command to DMI.\n");
-
- // open the dmi_res->guest_tx_fh to send command to DMI
- if (dmi_res->guest_tx_fh < 0)
- dmi_res->guest_tx_fh = open(dmi_res->guest_tx_fname, O_WRONLY |
O_NONBLOCK);
-
- // handle failed opens dmi_res->guest_tx_fh
- if (dmi_res->guest_tx_fh < 0){
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "VTPM ERROR: Can't open outbound
fh to dmi.\n");
- status = TPM_IOERROR;
- goto abort_with_error;
- }
-
- //Forward TPM CMD stamped with dmi_id to DMI for handling
- if (cmd_size) {
- dmi_cmd = (BYTE *) malloc(VTPM_COMMAND_HEADER_SIZE_SRV + cmd_size);
- dmi_cmd_size = VTPM_COMMAND_HEADER_SIZE_SRV + cmd_size;
- memcpy(dmi_cmd, cmd_header, VTPM_COMMAND_HEADER_SIZE_SRV);
- memcpy(dmi_cmd + VTPM_COMMAND_HEADER_SIZE_SRV, in_param, cmd_size);
- size_write = write(dmi_res->guest_tx_fh, dmi_cmd, dmi_cmd_size);
-
- if (size_write > 0) {
- vtpmhandlerloginfo(VTPM_LOG_VTPM_DEEP, "SENT (DMI): 0x");
- for (i=0; i<VTPM_COMMAND_HEADER_SIZE_SRV + cmd_size; i++) {
- vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "%x ", dmi_cmd[i]);
- }
- vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "\n");
- } else {
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Error writing to DMI.
Aborting... \n");
- close(dmi_res->guest_tx_fh);
- dmi_res->guest_tx_fh = -1;
- status = TPM_IOERROR;
- goto abort_with_error;
- }
- free(dmi_cmd);
- } else {
- dmi_cmd_size = VTPM_COMMAND_HEADER_SIZE_SRV;
- size_write = write(dmi_res->guest_tx_fh, cmd_header,
VTPM_COMMAND_HEADER_SIZE_SRV );
- if (size_write > 0) {
- for (i=0; i<VTPM_COMMAND_HEADER_SIZE_SRV; i++)
- vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "%x ",
cmd_header[i]);
-
- vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "\n");
- } else {
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Error writing to DMI.
Aborting... \n");
- close(dmi_res->guest_tx_fh);
- dmi_res->guest_tx_fh = -1;
- status = TPM_IOERROR;
- goto abort_with_error;
- }
- }
-
- if (size_write != (int) dmi_cmd_size)
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Could not write entire command
to DMI (%d/%d)\n", size_write, dmi_cmd_size);
- buffer_free(command_buf);
-
- // Open vtpm_globals->guest_rx_fh to receive DMI response
- if (vtpm_globals->guest_rx_fh < 0)
- vtpm_globals->guest_rx_fh = open(GUEST_RX_FIFO, O_RDONLY);
-
- // Handle open failures
- if (vtpm_globals->guest_rx_fh < 0){
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Can't open inbound fh to
dmi.\n");
- status = TPM_IOERROR;
- goto abort_with_error;
- }
-
- // Read header for response to TPM command from DMI
- size_read = read( vtpm_globals->guest_rx_fh, cmd_header,
VTPM_COMMAND_HEADER_SIZE_SRV);
- if (size_read > 0) {
- vtpmhandlerloginfo(VTPM_LOG_VTPM_DEEP, "RECV (DMI): 0x");
- for (i=0; i<size_read; i++)
- vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "%x ", cmd_header[i]);
-
- } else {
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Error reading from DMI.
Aborting... \n");
- close(vtpm_globals->guest_rx_fh);
- vtpm_globals->guest_rx_fh = -1;
- status = TPM_IOERROR;
- goto abort_with_error;
- }
-
- if (size_read < (int) VTPM_COMMAND_HEADER_SIZE_SRV) {
- //vtpmdeepsublog("\n");
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Command from DMI shorter than
normal header. Aborting...\n");
- status = TPM_IOERROR;
- goto abort_with_error;
- }
-
- // Unpack response from DMI for TPM command
- BSG_UnpackList(cmd_header, 4,
- BSG_TYPE_UINT32, &dmi,
- BSG_TPM_TAG, &tag,
- BSG_TYPE_UINT32, &in_param_size,
- BSG_TPM_COMMAND_CODE, &status );
-
- // If response has parameters, read them.
- // Note that in_param_size is in the client's context
- cmd_size = in_param_size - VTPM_COMMAND_HEADER_SIZE_CLT;
- if (cmd_size > 0) {
- in_param = (BYTE *) malloc(cmd_size);
- size_read = read( vtpm_globals->guest_rx_fh, in_param, cmd_size);
- if (size_read > 0) {
- for (i=0; i<size_read; i++)
- vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "%x ", in_param[i]);
-
- } else {
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Error reading from BE.
Aborting... \n");
- close(vtpm_globals->guest_rx_fh);
- vtpm_globals->guest_rx_fh = -1;
- status = TPM_IOERROR;
- goto abort_with_error;
- }
- vtpmhandlerloginfomore(VTPM_LOG_VTPM, "\n");
-
- if (size_read < (int)cmd_size) {
- vtpmhandlerloginfomore(VTPM_LOG_VTPM, "\n");
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Command read(%d) from DMI is
shorter than header indicates(%d). Aborting...\n", size_read, cmd_size);
- status = TPM_IOERROR;
- goto abort_with_error;
- }
- } else {
- in_param = NULL;
- vtpmhandlerloginfomore(VTPM_LOG_VTPM, "\n");
- }
-
- if (buffer_init_convert(result_buf, cmd_size, in_param) !=
TPM_SUCCESS) {
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Failed to setup buffers.
Aborting...\n");
- status = TPM_FAIL;
- goto abort_with_error;
- }
-
- vtpmhandlerloginfo(VTPM_LOG_VTPM, "Sending DMI's response to
guest.\n");
- } // end else for if (dmi==0)
-
- } else { // This is a DMI lister thread. Thus this is from a DMI
- // Raw TPM commands are not supported from the DMI
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Attempt to use unsupported direct
access to TPM.\n");
- vtpmhandlerloginfo(VTPM_LOG_VTPM_DEEP, "Bad Command. dmi:%d, tag:%d,
size:%d, ord:%d, Params: ", dmi, tag, in_param_size, ord);
- for (i=0; i<cmd_size; i++)
- vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "%x ", in_param[i]);
-
- vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "\n");
-
- status = TPM_FAIL;
- } // end else for if BE Listener
-#endif
-
- } // end else for is VTPM Command
-
- // This marks the beginning of preparing response to be sent out.
- // Errors while handling responses jump here to reply with error messages
- // NOTE: Currently there are no recoverable errors in multi-VM mode. If one
- // is added to the code, this ifdef should be removed.
- // Also note this is NOT referring to errors in commands, but rather
- // this is about I/O errors and such.
-#ifndef VTPM_MULTI_VM
- abort_with_error:
-#endif
-
- // Open tx_fh in preperation to send reponse back
- if (*tx_fh < 0) {
-#ifdef VTPM_MULTI_VM
- *tx_fh = open(VTPM_BE_DEV, O_RDWR);
-#else
- if (threadType == BE_LISTENER_THREAD)
- #ifdef DUMMY_BACKEND
- *tx_fh = open("/tmp/out.fifo", O_RDWR);
- #else
- *tx_fh = open(VTPM_BE_DEV, O_RDWR);
- #endif
- else // DMI Listener
- *tx_fh = open(dmi_res->vtpm_tx_fname, O_WRONLY);
-#endif
- }
-
-
- // Handle failed open
- if (*tx_fh < 0) {
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "VTPM ERROR: Can't open outbound
fh.\n");
-#ifdef VTPM_MULTI_VM
- return TPM_IOERROR;
-#else
- *ret_value = TPM_IOERROR;
- pthread_exit(ret_value);
-#endif
- }
-
- // Prepend VTPM header with destination DM stamped
- out_param_size = buffer_len(result_buf);
- out_message_size = VTPM_COMMAND_HEADER_SIZE_CLT + out_param_size;
- out_message_size_full = VTPM_COMMAND_HEADER_SIZE_SRV + out_param_size;
- out_message = (BYTE *) malloc (out_message_size_full);
-
- BSG_PackList(out_message, 4,
- BSG_TYPE_UINT32, (BYTE *) &dmi,
- BSG_TPM_TAG, (BYTE *) &tag,
- BSG_TYPE_UINT32, (BYTE *) &out_message_size,
- BSG_TPM_RESULT, (BYTE *) &status);
-
- if (buffer_len(result_buf) > 0)
- memcpy(out_message + VTPM_COMMAND_HEADER_SIZE_SRV, result_buf->bytes,
out_param_size);
-
-
- //Note: Send message + dmi_id
- size_write = write(*tx_fh, out_message, out_message_size_full );
- if (size_write > 0) {
- vtpmhandlerloginfo(VTPM_LOG_VTPM_DEEP, "SENT: 0x");
- for (i=0; i < out_message_size_full; i++)
- vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "%x ", out_message[i]);
-
- vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "\n");
- } else {
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Error writing to BE. Aborting...
\n");
- close(*tx_fh);
- *tx_fh = -1;
- goto abort_command;
- }
- free(out_message);
-
- if (size_write < (int)out_message_size_full) {
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "Unable to write full command to BE
(%d/%d)\n", size_write, out_message_size_full);
- goto abort_command;
- }
-
- // On certain failures an error message cannot be sent.
- // This marks the beginning of cleanup in preperation for the next command.
- abort_command:
- //free buffers
- bzero(cmd_header, VTPM_COMMAND_HEADER_SIZE_SRV);
- //free(in_param); // This was converted to command_buf. No need to free
- if (command_buf != result_buf)
- buffer_free(result_buf);
-
- buffer_free(command_buf);
-
-#ifndef VTPM_MULTI_VM
- if (threadType != BE_LISTENER_THREAD) {
-#endif
- if ( (vtpm_globals->DMI_table_dirty) &&
- (VTPM_SaveService() != TPM_SUCCESS) ) {
- vtpmhandlerlogerror(VTPM_LOG_VTPM, "ERROR: Unable to save manager
data.\n");
- }
-#ifndef VTPM_MULTI_VM
- }
-#endif
-
- } // End while(1)
-
-}
-
-
///////////////////////////////////////////////////////////////////////////////
-TPM_RESULT VTPM_Init_Service() {
+TPM_RESULT VTPM_Init_Manager() {
TPM_RESULT status = TPM_FAIL, serviceStatus;
BYTE *randomsead;
UINT32 randomsize;
@@ -749,19 +188,13 @@ TPM_RESULT VTPM_Init_Service() {
goto abort_egress;
}
memset(vtpm_globals, 0, sizeof(VTPM_GLOBALS));
- vtpm_globals->be_fh = -1;
-
-#ifndef VTPM_MULTI_VM
- vtpm_globals->vtpm_rx_fh = -1;
- vtpm_globals->guest_rx_fh = -1;
+
vtpm_globals->connected_dmis = 0;
-#endif
+
if ((vtpm_globals->dmi_map = create_hashtable(10, hashfunc32, equals32)) ==
NULL){
status = TPM_FAIL;
goto abort_egress;
}
-
- vtpm_globals->DMI_table_dirty = FALSE;
// Create new TCS Object
vtpm_globals->manager_tcs_handle = 0;
@@ -783,13 +216,14 @@ TPM_RESULT VTPM_Init_Service() {
&vtpm_globals->keyAuth) );
vtpm_globals->keyAuth.fContinueAuthSession = TRUE;
- // If failed, create new Service.
- serviceStatus = VTPM_LoadService();
+ // If failed, create new Manager.
+ serviceStatus = VTPM_LoadManagerData();
if (serviceStatus == TPM_IOERROR) {
- vtpmloginfo(VTPM_LOG_VTPM, "Failed to read service file. Assuming first
time initialization.\n");
- TPMTRYRETURN( VTPM_Create_Service() );
+ vtpmloginfo(VTPM_LOG_VTPM, "Failed to read manager file. Assuming first
time initialization.\n");
+ TPMTRYRETURN( VTPM_Create_Manager() );
+ TPMTRYRETURN( VTPM_SaveManagerData() );
} else if (serviceStatus != TPM_SUCCESS) {
- vtpmlogerror(VTPM_LOG_VTPM, "Failed to read existing service file");
+ vtpmlogerror(VTPM_LOG_VTPM, "Failed to read existing manager file");
exit(1);
}
@@ -805,8 +239,6 @@ TPM_RESULT VTPM_Init_Service() {
// Create entry for Dom0 for control messages
TPMTRYRETURN( VTPM_Handle_New_DMI(NULL) );
-
- // --------------------- Command handlers ---------------------------
goto egress;
@@ -815,8 +247,9 @@ TPM_RESULT VTPM_Init_Service() {
return(status);
}
-
-void VTPM_Stop_Service() {
+
+///////////////////////////////////////////////////////////////////////////////
+void VTPM_Stop_Manager() {
VTPM_DMI_RESOURCE *dmi_res;
struct hashtable_itr *dmi_itr;
@@ -832,7 +265,7 @@ void VTPM_Stop_Service() {
free (dmi_itr);
}
- if ( (vtpm_globals->DMI_table_dirty) && (VTPM_SaveService() != TPM_SUCCESS) )
+ if ( VTPM_SaveManagerData() != TPM_SUCCESS )
vtpmlogerror(VTPM_LOG_VTPM, "Unable to save manager data.\n");
TCS_CloseContext(vtpm_globals->manager_tcs_handle);
@@ -841,7 +274,6 @@ void VTPM_Stop_Service() {
hashtable_destroy(vtpm_globals->dmi_map, 1);
free(vtpm_globals);
- close(vtpm_globals->be_fh);
Crypto_Exit();
vtpmloginfo(VTPM_LOG_VTPM, "VTPM Manager stopped.\n");
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/vtpm_manager/manager/vtpm_manager.h
--- a/tools/vtpm_manager/manager/vtpm_manager.h Mon May 22 08:53:26 2006 -0600
+++ b/tools/vtpm_manager/manager/vtpm_manager.h Mon May 22 14:13:38 2006 -0600
@@ -40,32 +40,30 @@
#ifndef __VTPM_MANAGER_H__
#define __VTPM_MANAGER_H__
-#include "tcg.h"
-
#define VTPM_TAG_REQ 0x01c1
#define VTPM_TAG_RSP 0x01c4
#define COMMAND_BUFFER_SIZE 4096
// Header sizes. Note Header MAY include the DMI
-#define VTPM_COMMAND_HEADER_SIZE_SRV ( sizeof(UINT32) + sizeof(TPM_TAG) +
sizeof(UINT32) + sizeof(TPM_COMMAND_CODE))
-#define VTPM_COMMAND_HEADER_SIZE_CLT ( sizeof(TPM_TAG) +
sizeof(UINT32) + sizeof(TPM_COMMAND_CODE))
-
-// ********************** Public Functions *************************
-TPM_RESULT VTPM_Init_Service(); // Start VTPM Service
-void VTPM_Stop_Service(); // Stop VTPM Service
-#ifdef VTPM_MULTI_VM
-int VTPM_Service_Handler();
-#else
-void *VTPM_Service_Handler(void *threadTypePtr);
-#endif
+#define VTPM_COMMAND_HEADER_SIZE_CLT ( 2 + 4 + 4)
+// sizeof(TPM_TAG + UINT32 + TPM_COMMAND_CODE)
+#define VTPM_COMMAND_HEADER_SIZE_SRV ( 4 + VTPM_COMMAND_HEADER_SIZE_CLT )
+// sizeof( UINT32 + VTPM_COMMAND_HEADER_SIZE_CLT)
//************************ Command Codes ****************************
-#define VTPM_ORD_OPEN 1 // ULM Creates New DMI
-#define VTPM_ORD_CLOSE 2 // ULM Closes a DMI
-#define VTPM_ORD_DELETE 3 // ULM Permemently Deletes DMI
-#define VTPM_ORD_SAVENVM 4 // DMI requests Secrets Unseal
-#define VTPM_ORD_LOADNVM 5 // DMI requests Secrets Saved
-#define VTPM_ORD_TPMCOMMAND 6 // DMI issues HW TPM Command
+#define VTPM_ORD_BASE 0x0000
+#define VTPM_PRIV_MASK 0x01000000 // Priviledged VTPM Command
+#define VTPM_PRIV_BASE (VTPM_ORD_BASE | VTPM_PRIV_MASK)
+
+// Non-priviledged VTPM Commands (From DMI's)
+#define VTPM_ORD_SAVENVM (VTPM_ORD_BASE + 1) // DMI Saves Secrets
+#define VTPM_ORD_LOADNVM (VTPM_ORD_BASE + 2) // DMI Loads Secrets
+#define VTPM_ORD_TPMCOMMAND (VTPM_ORD_BASE + 3) // DMI issues HW TPM Command
+
+// Priviledged VTPM Commands (From management console)
+#define VTPM_ORD_OPEN (VTPM_PRIV_BASE + 1) // Creates/reopens DMI
+#define VTPM_ORD_CLOSE (VTPM_PRIV_BASE + 2) // Closes a DMI
+#define VTPM_ORD_DELETE (VTPM_PRIV_BASE + 3) // Permemently Deletes DMI
//************************ Return Codes ****************************
#define VTPM_SUCCESS 0
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/vtpm_manager/manager/vtpmd.c
--- a/tools/vtpm_manager/manager/vtpmd.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/vtpm_manager/manager/vtpmd.c Mon May 22 14:13:38 2006 -0600
@@ -38,21 +38,67 @@
// ===================================================================
#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include <signal.h>
-#include <sys/types.h>
-#include <unistd.h>
+#include <string.h>
+#include <pthread.h>
#include "vtpm_manager.h"
#include "vtpmpriv.h"
#include "tcg.h"
#include "log.h"
-
-#ifndef VTPM_MULTI_VM
- #include <pthread.h>
-#endif
+#include "vtpm_ipc.h"
+
+
+#define TPM_EMULATOR_PATH "/usr/bin/vtpmd"
+
+#define VTPM_BE_FNAME "/dev/vtpm"
+#define VTPM_DUMMY_TX_BE_FNAME "/var/vtpm/fifos/dummy_out.fifo"
+#define VTPM_DUMMY_RX_BE_FNAME "/var/vtpm/fifos/dummy_in.fifo"
+#define VTPM_TX_TPM_FNAME "/var/vtpm/fifos/tpm_cmd_to_%d.fifo"
+#define VTPM_RX_TPM_FNAME "/var/vtpm/fifos/tpm_rsp_from_all.fifo"
+#define VTPM_TX_VTPM_FNAME "/var/vtpm/fifos/vtpm_rsp_to_%d.fifo"
+#define VTPM_RX_VTPM_FNAME "/var/vtpm/fifos/vtpm_cmd_from_all.fifo"
+#define VTPM_TX_HP_FNAME "/var/vtpm/fifos/to_console.fifo"
+#define VTPM_RX_HP_FNAME "/var/vtpm/fifos/from_console.fifo"
+
+
+#define GUEST_TX_FIFO "/var/vtpm/fifos/guest-to-%d.fifo"
+#define GUEST_RX_FIFO "/var/vtpm/fifos/guest-from-all.fifo"
+
+#define VTPM_TX_FIFO "/var/vtpm/fifos/vtpm-to-%d.fifo"
+#define VTPM_RX_FIFO "/var/vtpm/fifos/vtpm-from-all.fifo"
+
+
+struct vtpm_thread_params_s {
+ vtpm_ipc_handle_t *tx_ipc_h;
+ vtpm_ipc_handle_t *rx_ipc_h;
+ BOOL fw_tpm;
+ vtpm_ipc_handle_t *fw_tx_ipc_h;
+ vtpm_ipc_handle_t *fw_rx_ipc_h;
+ BOOL is_priv;
+ char *thread_name;
+};
+
+// This is needed to all extra_close_dmi to close this to prevent a
+// broken pipe when no DMIs are left.
+static vtpm_ipc_handle_t *g_rx_tpm_ipc_h;
+
+void *vtpm_manager_thread(void *arg_void) {
+ TPM_RESULT *status = (TPM_RESULT *) malloc(sizeof(TPM_RESULT) );
+ struct vtpm_thread_params_s *arg = (struct vtpm_thread_params_s *) arg_void;
+
+ *status = VTPM_Manager_Handler(arg->tx_ipc_h, arg->rx_ipc_h,
+ arg->fw_tpm, arg->fw_tx_ipc_h,
arg->fw_rx_ipc_h,
+ arg->is_priv, arg->thread_name);
+
+ return (status);
+}
+
void signal_handler(int reason) {
-#ifndef VTPM_MULTI_VM
-
if (pthread_equal(pthread_self(), vtpm_globals->master_pid)) {
vtpmloginfo(VTPM_LOG_VTPM, "VTPM Manager shutting down for signal %d.\n",
reason);
} else {
@@ -60,71 +106,258 @@ void signal_handler(int reason) {
vtpmloginfo(VTPM_LOG_VTPM, "Child shutting down\n");
pthread_exit(NULL);
}
+
+ VTPM_Stop_Manager();
+ exit(-1);
+}
+
+struct sigaction ctl_c_handler;
+
+TPM_RESULT VTPM_New_DMI_Extra(VTPM_DMI_RESOURCE *dmi_res) {
+
+ TPM_RESULT status = TPM_SUCCESS;
+ int fh;
+ char dmi_id_str[11]; // UINT32s are up to 10 digits + NULL
+ char *tx_vtpm_name, *tx_tpm_name;
+ struct stat file_info;
+
+ if (dmi_res->dmi_id == VTPM_CTL_DM) {
+ dmi_res->tx_tpm_ipc_h = NULL;
+ dmi_res->rx_tpm_ipc_h = NULL;
+ dmi_res->tx_vtpm_ipc_h = NULL;
+ dmi_res->rx_vtpm_ipc_h = NULL;
+ } else {
+ // Create a pair of fifo pipes
+ dmi_res->rx_tpm_ipc_h = NULL;
+ dmi_res->rx_vtpm_ipc_h = NULL;
+
+ if ( ((dmi_res->tx_tpm_ipc_h = (vtpm_ipc_handle_t *) malloc
(sizeof(vtpm_ipc_handle_t))) == NULL ) ||
+ ((dmi_res->tx_vtpm_ipc_h =(vtpm_ipc_handle_t *) malloc
(sizeof(vtpm_ipc_handle_t))) == NULL ) ||
+ ((tx_tpm_name = (char *) malloc(11 + strlen(VTPM_TX_TPM_FNAME))) ==
NULL ) ||
+ ((tx_vtpm_name =(char *) malloc(11 + strlen(VTPM_TX_VTPM_FNAME))) ==
NULL) ) {
+ status =TPM_RESOURCES;
+ goto abort_egress;
+ }
+
+ sprintf(tx_tpm_name, VTPM_TX_TPM_FNAME, (uint32_t) dmi_res->dmi_id);
+ sprintf(tx_vtpm_name, VTPM_TX_VTPM_FNAME, (uint32_t) dmi_res->dmi_id);
+
+ if ( (vtpm_ipc_init(dmi_res->tx_tpm_ipc_h, tx_tpm_name, O_WRONLY |
O_NONBLOCK, TRUE) != 0) ||
+ (vtpm_ipc_init(dmi_res->tx_vtpm_ipc_h, tx_vtpm_name, O_WRONLY, TRUE)
!= 0) ) { //FIXME: O_NONBLOCK?
+ status = TPM_IOERROR;
+ goto abort_egress;
+ }
+
+ // Measure DMI
+ // FIXME: This will measure DMI. Until then use a fixed DMI_Measurement
value
+ // Also, this mechanism is specific to 1 VM.
+ /*
+ fh = open(TPM_EMULATOR_PATH, O_RDONLY);
+ stat_ret = fstat(fh, &file_stat);
+ if (stat_ret == 0)
+ dmi_size = file_stat.st_size;
+ else {
+ vtpmlogerror(VTPM_LOG_VTPM, "Could not open tpm_emulator!!\n");
+ status = TPM_IOERROR;
+ goto abort_egress;
+ }
+ dmi_buffer
+ */
+ memset(&dmi_res->DMI_measurement, 0xcc, sizeof(TPM_DIGEST));
+
+
+ // Launch DMI
+ sprintf(dmi_id_str, "%d", (int) dmi_res->dmi_id);
+#ifdef MANUAL_DM_LAUNCH
+ vtpmlogerror(VTPM_LOG_VTPM, "Manually start VTPM with dmi=%s now.\n",
dmi_id_str);
+ dmi_res->dmi_pid = 0;
+#else
+ pid_t pid = fork();
+
+ if (pid == -1) {
+ vtpmlogerror(VTPM_LOG_VTPM, "Could not fork to launch vtpm\n");
+ status = TPM_RESOURCES;
+ goto abort_egress;
+ } else if (pid == 0) {
+ if ( stat(dmi_res->NVMLocation, &file_info) == -1)
+ execl (TPM_EMULATOR_PATH, "vtmpd", "clear", dmi_id_str, NULL);
+ else
+ execl (TPM_EMULATOR_PATH, "vtpmd", "save", dmi_id_str, NULL);
+
+ // Returning from these at all is an error.
+ vtpmlogerror(VTPM_LOG_VTPM, "Could not exec to launch vtpm\n");
+ } else {
+ dmi_res->dmi_pid = pid;
+ vtpmloginfo(VTPM_LOG_VTPM, "Launching DMI on PID = %d\n", pid);
+ }
+#endif // MANUAL_DM_LAUNCH
+
+ } // If DMI = VTPM_CTL_DM
+ status = TPM_SUCCESS;
+
+abort_egress:
+ return (status);
+}
+
+TPM_RESULT VTPM_Close_DMI_Extra(VTPM_DMI_RESOURCE *dmi_res) {
+ TPM_RESULT status = TPM_SUCCESS;
+
+ if (vtpm_globals->connected_dmis == 0) {
+ // No more DMI's connected. Close fifo to prevent a broken pipe.
+ // This is hackish. Need to think of another way.
+ vtpm_ipc_close(g_rx_tpm_ipc_h);
+ }
+
+
+ if (dmi_res->dmi_id != VTPM_CTL_DM) {
+ vtpm_ipc_close(dmi_res->tx_tpm_ipc_h);
+ vtpm_ipc_close(dmi_res->tx_vtpm_ipc_h);
+
+ free(dmi_res->tx_tpm_ipc_h->name);
+ free(dmi_res->tx_vtpm_ipc_h->name);
+
+#ifndef MANUAL_DM_LAUNCH
+ if (dmi_res->dmi_id != VTPM_CTL_DM) {
+ if (dmi_res->dmi_pid != 0) {
+ vtpmloginfo(VTPM_LOG_VTPM, "Killing dmi on pid %d.\n",
dmi_res->dmi_pid);
+ if (kill(dmi_res->dmi_pid, SIGKILL) !=0) {
+ vtpmloginfo(VTPM_LOG_VTPM, "DMI on pid %d is already dead.\n",
dmi_res->dmi_pid);
+ } else if (waitpid(dmi_res->dmi_pid, NULL, 0) != dmi_res->dmi_pid) {
+ vtpmlogerror(VTPM_LOG_VTPM, "DMI on pid %d failed to stop.\n",
dmi_res->dmi_pid);
+ status = TPM_FAIL;
+ }
+ } else {
+ vtpmlogerror(VTPM_LOG_VTPM, "Could not kill dmi because it's pid was
0.\n");
+ status = TPM_FAIL;
+ }
+ }
#endif
- VTPM_Stop_Service();
- exit(-1);
-}
-
-struct sigaction ctl_c_handler;
+
+ } //endif ! dom0
+ return status;
+}
+
int main(int argc, char **argv) {
+ vtpm_ipc_handle_t *tx_be_ipc_h, *rx_be_ipc_h, rx_tpm_ipc_h, rx_vtpm_ipc_h,
tx_hp_ipc_h, rx_hp_ipc_h;
+ struct vtpm_thread_params_s be_thread_params, dmi_thread_params,
hp_thread_params;
+ pthread_t be_thread, dmi_thread, hp_thread;
+
+#ifdef DUMMY_BACKEND
+ vtpm_ipc_handle_t tx_dummy_ipc_h, rx_dummy_ipc_h;
+#else
+ vtpm_ipc_handle_t real_be_ipc_h;
+#endif
vtpmloginfo(VTPM_LOG_VTPM, "Starting VTPM.\n");
-
- if (VTPM_Init_Service() != TPM_SUCCESS) {
+
+ // -------------------- Initialize Manager -----------------
+ if (VTPM_Init_Manager() != TPM_SUCCESS) {
vtpmlogerror(VTPM_LOG_VTPM, "Closing vtpmd due to error during
startup.\n");
return -1;
}
+ // -------------------- Setup Ctrl+C Handlers --------------
ctl_c_handler.sa_handler = signal_handler;
sigemptyset(&ctl_c_handler.sa_mask);
ctl_c_handler.sa_flags = 0;
if (sigaction(SIGINT, &ctl_c_handler, NULL) == -1)
- vtpmlogerror(VTPM_LOG_VTPM, "Could not install SIGINT handler. Ctl+break
will not stop service gently.\n");
+ vtpmlogerror(VTPM_LOG_VTPM, "Could not install SIGINT handler. Ctl+break
will not stop manager gently.\n");
// For easier debuggin with gdb
if (sigaction(SIGHUP, &ctl_c_handler, NULL) == -1)
- vtpmlogerror(VTPM_LOG_VTPM, "Could not install SIGHUP handler. Ctl+break
will not stop service gently.\n");
-
-#ifdef VTPM_MULTI_VM
- TPM_RESULT status = VTPM_Service_Handler();
-
- if (status != TPM_SUCCESS)
- vtpmlogerror(VTPM_LOG_VTPM, "VTPM Manager exited with status %s. It never
should exit.\n", tpm_get_error_name(status));
-
- return -1;
-#else
+ vtpmlogerror(VTPM_LOG_VTPM, "Could not install SIGHUP handler. Ctl+break
will not stop manager gently.\n");
+
sigset_t sig_mask;
-
sigemptyset(&sig_mask);
sigaddset(&sig_mask, SIGPIPE);
sigprocmask(SIG_BLOCK, &sig_mask, NULL);
- //pthread_mutex_init(&vtpm_globals->dmi_mutex, NULL);
- pthread_t be_thread, dmi_thread;
- int betype_be, dmitype_dmi;
-
+
+ // ------------------- Set up file ipc structures ----------
+#ifdef DUMMY_BACKEND
+ if ( (vtpm_ipc_init(&tx_dummy_ipc_h, VTPM_DUMMY_TX_BE_FNAME, O_RDWR, TRUE)
!= 0) ||
+ (vtpm_ipc_init(&rx_dummy_ipc_h, VTPM_DUMMY_RX_BE_FNAME, O_RDWR, TRUE)
!= 0) ) {
+
+ vtpmlogerror(VTPM_LOG_VTPM, "Unable to create Dummy BE FIFOs.\n");
+ exit(-1);
+ }
+
+ tx_be_ipc_h = &tx_dummy_ipc_h;
+ rx_be_ipc_h = &rx_dummy_ipc_h;
+#else
+ vtpm_ipc_init(&real_be_ipc_h, VTPM_BE_FNAME, O_RDWR, FALSE);
+
+ tx_be_ipc_h = &real_be_ipc_h;
+ rx_be_ipc_h = &real_be_ipc_h;
+#endif
+
+ if ( (vtpm_ipc_init(&rx_tpm_ipc_h, VTPM_RX_TPM_FNAME, O_RDONLY, TRUE) != 0)
||
+ (vtpm_ipc_init(&rx_vtpm_ipc_h, VTPM_RX_VTPM_FNAME, O_RDWR, TRUE) != 0)
|| //FIXME: O_RDONLY?
+ (vtpm_ipc_init(&tx_hp_ipc_h, VTPM_TX_HP_FNAME, O_RDWR, TRUE) != 0)
||
+ (vtpm_ipc_init(&rx_hp_ipc_h, VTPM_RX_HP_FNAME, O_RDWR, TRUE) != 0) ) {
+ vtpmlogerror(VTPM_LOG_VTPM, "Unable to create initial FIFOs.\n");
+ exit(-1);
+ }
+
+ g_rx_tpm_ipc_h = &rx_tpm_ipc_h;
+
+ // -------------------- Set up thread params -------------
+
+ be_thread_params.tx_ipc_h = tx_be_ipc_h;
+ be_thread_params.rx_ipc_h = rx_be_ipc_h;
+ be_thread_params.fw_tpm = TRUE;
+ be_thread_params.fw_tx_ipc_h = NULL;
+ be_thread_params.fw_rx_ipc_h = &rx_tpm_ipc_h;
+ be_thread_params.is_priv = TRUE; //FIXME: Change when HP
is up
+ be_thread_params.thread_name = "Backend Listener";
+
+ dmi_thread_params.tx_ipc_h = NULL;
+ dmi_thread_params.rx_ipc_h = &rx_vtpm_ipc_h;
+ dmi_thread_params.fw_tpm = FALSE;
+ dmi_thread_params.fw_tx_ipc_h = NULL;
+ dmi_thread_params.fw_rx_ipc_h = NULL;
+ dmi_thread_params.is_priv = FALSE;
+ dmi_thread_params.thread_name = "VTPM Listeners";
+
+ hp_thread_params.tx_ipc_h = &tx_hp_ipc_h;
+ hp_thread_params.rx_ipc_h = &rx_hp_ipc_h;
+ hp_thread_params.fw_tpm = FALSE;
+ hp_thread_params.fw_tx_ipc_h = NULL;
+ hp_thread_params.fw_rx_ipc_h = NULL;
+ hp_thread_params.is_priv = TRUE;
+ hp_thread_params.thread_name = "Hotplug Listener";
+
+ // --------------------- Launch Threads -----------------
+
+ vtpm_lock_init();
+
vtpm_globals->master_pid = pthread_self();
- betype_be = BE_LISTENER_THREAD;
- if (pthread_create(&be_thread, NULL, VTPM_Service_Handler, &betype_be) != 0)
{
+ if (pthread_create(&be_thread, NULL, vtpm_manager_thread, &be_thread_params)
!= 0) {
vtpmlogerror(VTPM_LOG_VTPM, "Failed to launch BE Thread.\n");
exit(-1);
}
- dmitype_dmi = DMI_LISTENER_THREAD;
- if (pthread_create(&dmi_thread, NULL, VTPM_Service_Handler, &dmitype_dmi) !=
0) {
+ if (pthread_create(&dmi_thread, NULL, vtpm_manager_thread,
&dmi_thread_params) != 0) {
vtpmlogerror(VTPM_LOG_VTPM, "Failed to launch DMI Thread.\n");
exit(-1);
}
-
+
+
+// if (pthread_create(&hp_thread, NULL, vtpm_manager_thread,
&hp_thread_params) != 0) {
+// vtpmlogerror(VTPM_LOG_VTPM, "Failed to launch HP Thread.\n");
+// exit(-1);
+// }
+
//Join the other threads until exit time.
pthread_join(be_thread, NULL);
pthread_join(dmi_thread, NULL);
-#endif
+ pthread_join(hp_thread, NULL);
vtpmlogerror(VTPM_LOG_VTPM, "VTPM Manager shut down unexpectedly.\n");
- VTPM_Stop_Service();
+ VTPM_Stop_Manager();
+ vtpm_lock_destroy();
return 0;
}
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/vtpm_manager/manager/vtpmpriv.h
--- a/tools/vtpm_manager/manager/vtpmpriv.h Mon May 22 08:53:26 2006 -0600
+++ b/tools/vtpm_manager/manager/vtpmpriv.h Mon May 22 14:13:38 2006 -0600
@@ -44,42 +44,24 @@
#include "tcs.h"
#include "buffer.h"
#include "crypto.h"
+#include "vtpm_ipc.h"
#define STATE_FILE "/var/vtpm/VTPM"
#define DMI_NVM_FILE "/var/vtpm/vtpm_dm_%d.data"
-#define VTPM_BE_DEV "/dev/vtpm"
#define VTPM_CTL_DM 0
-
-#ifndef VTPM_MUTLI_VM
- #include <sys/types.h>
- #define GUEST_TX_FIFO "/var/vtpm/fifos/guest-to-%d.fifo"
- #define GUEST_RX_FIFO "/var/vtpm/fifos/guest-from-all.fifo"
-
- #define VTPM_TX_FIFO "/var/vtpm/fifos/vtpm-to-%d.fifo"
- #define VTPM_RX_FIFO "/var/vtpm/fifos/vtpm-from-all.fifo"
-
- #define BE_LISTENER_THREAD 1
- #define DMI_LISTENER_THREAD 2
-
- // Seconds until DMI timeout. Timeouts result in DMI being out
- // of sync, which may require a reboot of DMI and guest to recover
- // from. Don't set this to low. Also note that DMI may issue a TPM
- // call so we should expect time to process at DMI + TPM processing.
- #define DMI_TIMEOUT 90
-#endif
-
// ------------------------ Private Structures -----------------------
typedef struct VTPM_DMI_RESOURCE_T {
- // I/O info for Manager to talk to DMI's over FIFOs
-#ifndef VTPM_MUTLI_VM
- int guest_tx_fh; // open GUEST_TX_FIFO
- int vtpm_tx_fh; // open VTPM_TX_FIFO
- char *guest_tx_fname; // open GUEST_TX_FIFO
- char *vtpm_tx_fname; // open VTPM_TX_FIFO
-
+ // I/O info for Manager to talk to DMI's and controllers
+ vtpm_ipc_handle_t *tx_vtpm_ipc_h; // TX VTPM Results to DMI
+ vtpm_ipc_handle_t *rx_vtpm_ipc_h; // RX VTPM Commands from DMI
+ vtpm_ipc_handle_t *tx_tpm_ipc_h; // TX TPM Commands to DMI
+ vtpm_ipc_handle_t *rx_tpm_ipc_h; // RX TPM Results from DMI
+
+#ifndef VTPM_MULTI_VM
pid_t dmi_pid;
#endif
+
// Non-persistent Information
bool connected;
UINT32 dmi_domain_id;
@@ -94,26 +76,19 @@ typedef struct VTPM_DMI_RESOURCE_T {
typedef struct tdVTPM_GLOBALS {
// Non-persistent data
- int be_fh; // File handle to ipc used to
communicate with backend
#ifndef VTPM_MULTI_VM
- int vtpm_rx_fh;
- int guest_rx_fh;
- int connected_dmis; // Used to close guest_rx when no
dmis are connected
-
pid_t master_pid;
#endif
+
+ int connected_dmis; // To close guest_rx when no dmis
are connected
+
struct hashtable *dmi_map; // Table of all DMI's known
indexed by persistent instance #
-#ifndef VTPM_MULTI_VM
- pthread_mutex_t dmi_map_mutex; //
-#endif
+
TCS_CONTEXT_HANDLE manager_tcs_handle; // TCS Handle used by manager
TPM_HANDLE storageKeyHandle; // Key used by persistent store
CRYPTO_INFO storageKey; // For software encryption
CRYPTO_INFO bootKey; // For saving table
TCS_AUTH keyAuth; // OIAP session for storageKey
- BOOL DMI_table_dirty; // Indicates that a command
- // has updated the DMI table
-
// Persistent Data
TPM_AUTHDATA owner_usage_auth; // OwnerAuth of real TPM
@@ -130,6 +105,18 @@ extern const TPM_AUTHDATA SRK_AUTH; //
extern const TPM_AUTHDATA SRK_AUTH; // SRK Well Known Auth Value
// ********************** Command Handler Prototypes ***********************
+
+// ********************** VTPM Functions *************************
+TPM_RESULT VTPM_Init_Manager(); // Start VTPM Service
+void VTPM_Stop_Manager(); // Stop VTPM Service
+TPM_RESULT VTPM_Manager_Handler(vtpm_ipc_handle_t *tx_ipc_h,
+ vtpm_ipc_handle_t *rx_ipc_h,
+ BOOL fw_tpm, // Should forward TPM cmds
+ vtpm_ipc_handle_t *fw_tx_ipc_h,
+ vtpm_ipc_handle_t *fw_rx_ipc_h,
+ BOOL is_priv,
+ char *client_name);
+
TPM_RESULT VTPM_Handle_Load_NVM( VTPM_DMI_RESOURCE *myDMI,
const buffer_t *inbuf,
buffer_t *outbuf);
@@ -148,8 +135,12 @@ TPM_RESULT VTPM_Handle_Close_DMI(const b
TPM_RESULT VTPM_Handle_Delete_DMI(const buffer_t *param_buf);
-TPM_RESULT VTPM_SaveService(void);
-TPM_RESULT VTPM_LoadService(void);
+TPM_RESULT VTPM_SaveManagerData(void);
+TPM_RESULT VTPM_LoadManagerData(void);
-TPM_RESULT close_dmi( VTPM_DMI_RESOURCE *dmi_res);
+TPM_RESULT VTPM_New_DMI_Extra(VTPM_DMI_RESOURCE *dmi_res);
+
+TPM_RESULT VTPM_Close_DMI_Extra(VTPM_DMI_RESOURCE *dmi_res);
+
+TPM_RESULT close_dmi(VTPM_DMI_RESOURCE *dmi_res);
#endif // __VTPMPRIV_H__
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/xenmon/xenbaked.c
--- a/tools/xenmon/xenbaked.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/xenmon/xenbaked.c Mon May 22 14:13:38 2006 -0600
@@ -35,6 +35,7 @@
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
@@ -46,7 +47,14 @@
#include <sys/select.h>
#include <xen/linux/evtchn.h>
-#include "xc_private.h"
+#define PERROR(_m, _a...) \
+do { \
+ int __saved_errno = errno; \
+ fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a , \
+ __saved_errno, strerror(__saved_errno)); \
+ errno = __saved_errno; \
+} while (0)
+
typedef struct { int counter; } atomic_t;
#define _atomic_read(v) ((v).counter)
@@ -326,77 +334,32 @@ void wait_for_event(void)
}
}
-void enable_tracing_or_die(int xc_handle)
-{
- int enable = 1;
- int tbsize = DEFAULT_TBUF_SIZE;
-
- if (xc_tbuf_enable(xc_handle, enable) != 0) {
- if (xc_tbuf_set_size(xc_handle, tbsize) != 0) {
- perror("set_size Hypercall failure");
- exit(1);
- }
- printf("Set default trace buffer allocation (%d pages)\n", tbsize);
- if (xc_tbuf_enable(xc_handle, enable) != 0) {
- perror("Could not enable trace buffers\n");
- exit(1);
- }
- }
- else
- printf("Tracing enabled\n");
-}
-
-void disable_tracing(void)
-{
- int enable = 0;
- int xc_handle = xc_interface_open();
-
- xc_tbuf_enable(xc_handle, enable);
- xc_interface_close(xc_handle);
-}
-
-
-/**
- * get_tbufs - get pointer to and size of the trace buffers
- * @mfn: location to store mfn of the trace buffers to
- * @size: location to store the size of a trace buffer to
- *
- * Gets the machine address of the trace pointer area and the size of the
- * per CPU buffers.
- */
-void get_tbufs(unsigned long *mfn, unsigned long *size)
-{
+static void get_tbufs(unsigned long *mfn, unsigned long *size)
+{
+ int xc_handle = xc_interface_open();
int ret;
- dom0_op_t op; /* dom0 op we'll build */
- int xc_handle = xc_interface_open(); /* for accessing control interface */
- unsigned int tbsize;
-
- enable_tracing_or_die(xc_handle);
-
- if (xc_tbuf_get_size(xc_handle, &tbsize) != 0) {
- perror("Failure to get tbuf info from Xen. Guess size is 0?");
- exit(1);
- }
- else
- printf("Current tbuf size: 0x%x\n", tbsize);
-
-
- op.cmd = DOM0_TBUFCONTROL;
- op.interface_version = DOM0_INTERFACE_VERSION;
- op.u.tbufcontrol.op = DOM0_TBUF_GET_INFO;
-
- ret = do_dom0_op(xc_handle, &op);
-
- xc_interface_close(xc_handle);
+
+ if ( xc_handle < 0 )
+ {
+ exit(EXIT_FAILURE);
+ }
+
+ ret = xc_tbuf_enable(xc_handle, DEFAULT_TBUF_SIZE, mfn, size);
if ( ret != 0 )
{
- PERROR("Failure to get trace buffer pointer from Xen");
- exit(EXIT_FAILURE);
- }
-
- *mfn = op.u.tbufcontrol.buffer_mfn;
- *size = op.u.tbufcontrol.size;
+ perror("Couldn't enable trace buffers");
+ exit(1);
+ }
+
+ xc_interface_close(xc_handle);
+}
+
+void disable_tracing(void)
+{
+ int xc_handle = xc_interface_open();
+ xc_tbuf_disable(xc_handle);
+ xc_interface_close(xc_handle);
}
/**
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/xenstore/xenstored_core.c Mon May 22 14:13:38 2006 -0600
@@ -461,7 +461,7 @@ static bool write_node(struct connection
+ node->num_perms*sizeof(node->perms[0])
+ node->datalen + node->childlen;
- if (data.dsize >= quota_max_entry_size)
+ if (domain_is_unprivileged(conn) && data.dsize >= quota_max_entry_size)
goto error;
data.dptr = talloc_size(node, data.dsize);
@@ -1811,6 +1811,21 @@ int main(int argc, char *argv[])
reopen_log();
+ /* make sure xenstored directory exists */
+ if (mkdir(xs_daemon_rundir(), 0755)) {
+ if (errno != EEXIST) {
+ perror("error: mkdir daemon rundir");
+ exit(-1);
+ }
+ }
+
+ if (mkdir(xs_daemon_rootdir(), 0755)) {
+ if (errno != EEXIST) {
+ perror("error: mkdir daemon rootdir");
+ exit(-1);
+ }
+ }
+
if (dofork) {
openlog("xenstored", 0, LOG_DAEMON);
daemonize();
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/xenstore/xenstored_domain.c
--- a/tools/xenstore/xenstored_domain.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/xenstore/xenstored_domain.c Mon May 22 14:13:38 2006 -0600
@@ -248,6 +248,11 @@ bool domain_can_read(struct connection *
{
struct xenstore_domain_interface *intf = conn->domain->interface;
return (intf->req_cons != intf->req_prod);
+}
+
+bool domain_is_unprivileged(struct connection *conn)
+{
+ return (conn && conn->domain && conn->domain->domid != 0);
}
bool domain_can_write(struct connection *conn)
@@ -587,7 +592,7 @@ void domain_entry_dec(struct connection
int domain_entry(struct connection *conn)
{
- return (conn && conn->domain && conn->domain->domid)
+ return (domain_is_unprivileged(conn))
? conn->domain->nbentry
: 0;
}
@@ -609,7 +614,7 @@ void domain_watch_dec(struct connection
int domain_watch(struct connection *conn)
{
- return (conn && conn->domain && conn->domain->domid)
+ return (domain_is_unprivileged(conn))
? conn->domain->nbwatch
: 0;
}
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/xenstore/xenstored_domain.h
--- a/tools/xenstore/xenstored_domain.h Mon May 22 08:53:26 2006 -0600
+++ b/tools/xenstore/xenstored_domain.h Mon May 22 14:13:38 2006 -0600
@@ -47,6 +47,8 @@ bool domain_can_read(struct connection *
bool domain_can_read(struct connection *conn);
bool domain_can_write(struct connection *conn);
+bool domain_is_unprivileged(struct connection *conn);
+
/* Quota manipulation */
void domain_entry_inc(struct connection *conn);
void domain_entry_dec(struct connection *conn);
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/xenstore/xs_lib.c
--- a/tools/xenstore/xs_lib.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/xenstore/xs_lib.c Mon May 22 14:13:38 2006 -0600
@@ -26,13 +26,13 @@
/* Common routines for the Xen store daemon and client library. */
-static const char *xs_daemon_rootdir(void)
+const char *xs_daemon_rootdir(void)
{
char *s = getenv("XENSTORED_ROOTDIR");
return (s ? s : "/var/lib/xenstored");
}
-static const char *xs_daemon_rundir(void)
+const char *xs_daemon_rundir(void)
{
char *s = getenv("XENSTORED_RUNDIR");
return (s ? s : "/var/run/xenstored");
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/xenstore/xs_lib.h
--- a/tools/xenstore/xs_lib.h Mon May 22 08:53:26 2006 -0600
+++ b/tools/xenstore/xs_lib.h Mon May 22 14:13:38 2006 -0600
@@ -46,6 +46,8 @@ struct xs_permissions
#define MAX_STRLEN(x) ((sizeof(x) * CHAR_BIT + CHAR_BIT-1) / 10 * 3 + 2)
/* Path for various daemon things: env vars can override. */
+const char *xs_daemon_rootdir(void);
+const char *xs_daemon_rundir(void);
const char *xs_daemon_socket(void);
const char *xs_daemon_socket_ro(void);
const char *xs_domain_dev(void);
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/xentrace/Makefile
--- a/tools/xentrace/Makefile Mon May 22 08:53:26 2006 -0600
+++ b/tools/xentrace/Makefile Mon May 22 14:13:38 2006 -0600
@@ -14,7 +14,7 @@ HDRS = $(wildcard *.h)
HDRS = $(wildcard *.h)
OBJS = $(patsubst %.c,%.o,$(wildcard *.c))
-BIN = xentrace tbctl setsize
+BIN = xentrace setsize
LIBBIN =
SCRIPTS = xentrace_format
MAN1 = $(wildcard *.1)
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/xentrace/setsize.c
--- a/tools/xentrace/setsize.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/xentrace/setsize.c Mon May 22 14:13:38 2006 -0600
@@ -5,33 +5,37 @@
int main(int argc, char * argv[])
{
- unsigned int size;
- int xc_handle = xc_interface_open();
+ unsigned long size;
+ int xc_handle = xc_interface_open();
- if (xc_tbuf_get_size(xc_handle, &size) != 0) {
- perror("Failure to get tbuf info from Xen. Guess size is 0");
- printf("This may mean that tracing is not enabled in xen.\n");
- // exit(1);
- }
- else
- printf("Current tbuf size: 0x%x\n", size);
+ if ( xc_tbuf_get_size(xc_handle, &size) != 0 )
+ {
+ perror("Failure to get tbuf info from Xen. Guess size is 0");
+ printf("This may mean that tracing is not enabled in xen.\n");
+ }
+ else
+ {
+ printf("Current tbuf size: 0x%lx\n", size);
+ }
+
+ if (argc < 2)
+ exit(0);
+
+ size = atol(argv[1]);
+
+ if ( xc_tbuf_set_size(xc_handle, size) != 0 )
+ {
+ perror("set_size Hypercall failure");
+ exit(1);
+ }
+ printf("set_size succeeded.\n");
- if (argc < 2)
- exit(0);
-
- size = atoi(argv[1]);
-
- if (xc_tbuf_set_size(xc_handle, size) != 0) {
- perror("set_size Hypercall failure");
- exit(1);
- }
- printf("set_size succeeded.\n");
+ if (xc_tbuf_get_size(xc_handle, &size) != 0)
+ perror("Failure to get tbuf info from Xen."
+ " Tracing must be enabled first");
+ else
+ printf("New tbuf size: 0x%lx\n", size);
- if (xc_tbuf_get_size(xc_handle, &size) != 0)
- perror("Failure to get tbuf info from Xen. Tracing must be enabled first");
- else
- printf("New tbuf size: 0x%x\n", size);
-
- xc_interface_close(xc_handle);
- return 0;
+ xc_interface_close(xc_handle);
+ return 0;
}
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/xentrace/xentrace.8
--- a/tools/xentrace/xentrace.8 Mon May 22 08:53:26 2006 -0600
+++ b/tools/xentrace/xentrace.8 Mon May 22 14:13:38 2006 -0600
@@ -35,6 +35,81 @@ all new records to the output
.B -s, --poll-sleep=p
set the time, p, (in milliseconds) to sleep between polling the buffers
for new data.
+.TP
+.B -c, --cpu-mask=c
+set cpu-mask
+.TP
+.B -e, --evt-mask=e
+set evt-mask
+.TP
+.B -?, --help
+Give this help list
+.TP
+.B --usage
+Give a short usage message
+.TP
+.B -V, --version
+Print program version
+
+.SS Event Classes (Masks)
+The following event classes (masks) can be used to filter the events being
+gathered by xentrace:
+.PP
+ \fIID\fP \fIDescription\fP
+.PP
+ 0x0001f000 TRC_GEN
+ 0x0002f000 TRC_SCHED
+ 0x0004f000 TRC_DOM0OP
+ 0x0008f000 TRC_VMX
+ 0x000af000 TRC_MEM
+ 0xfffff000 TRC_ALL
+
+
+.SS Event Subclasses (More Masks)
+The following event subclasses (masks) can also be used to filter the events
being
+gathered by xentrace:
+.PP
+ \fIID\fP \fIDescription\fP
+.PP
+ 0x00081000 TRC_VMXEXIT
+ 0x00082000 TRC_VMXTIMER
+ 0x00084000 TRC_VMXINT
+ 0x00088000 TRC_VMXIO
+
+
+.SS Events
+.B xentrace
+collects the following events from the trace buffer:
+.PP
+ \fIID\fP \fIDescription\fP
+.PP
+ 0x0002f001 TRC_SCHED_DOM_ADD
+ 0x0002f002 TRC_SCHED_DOM_REM
+ 0x0002f003 TRC_SCHED_SLEEP
+ 0x0002f004 TRC_SCHED_WAKE
+ 0x0002f005 TRC_SCHED_YIELD
+ 0x0002f006 TRC_SCHED_BLOCK
+ 0x0002f007 TRC_SCHED_SHUTDOWN
+ 0x0002f008 TRC_SCHED_CTL
+ 0x0002f009 TRC_SCHED_ADJDOM
+ 0x0002f010 TRC_SCHED_SWITCH
+ 0x0002f011 TRC_SCHED_S_TIMER_FN
+ 0x0002f012 TRC_SCHED_T_TIMER_FN
+ 0x0002f013 TRC_SCHED_DOM_TIMER_FN
+ 0x0002f014 TRC_SCHED_SWITCH_INFPREV
+ 0x0002f015 TRC_SCHED_SWITCH_INFNEXT
+
+ 0x000af001 TRC_MEM_PAGE_GRANT_MAP
+ 0x000af002 TRC_MEM_PAGE_GRANT_UNMAP
+ 0x000af003 TRC_MEM_PAGE_GRANT_TRANSFER
+
+ 0x00081001 TRC_VMX_VMEXIT
+ 0x00081002 TRC_VMX_VMENTRY
+
+ 0x00082001 TRC_VMX_TIMER_INTR
+
+ 0x00084001 TRC_VMX_INT
+.PP
.SH AUTHOR
Mark A. Williamson <mark.a.williamson@xxxxxxxxx>
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/xentrace/xentrace.c
--- a/tools/xentrace/xentrace.c Mon May 22 08:53:26 2006 -0600
+++ b/tools/xentrace/xentrace.c Mon May 22 14:13:38 2006 -0600
@@ -46,7 +46,7 @@ extern FILE *stderr;
/* sleep for this long (milliseconds) between checking the trace buffers */
#define POLL_SLEEP_MILLIS 100
-
+#define DEFAULT_TBUF_SIZE 20
/***** The code **************************************************************/
typedef struct settings_st {
@@ -101,32 +101,25 @@ void write_rec(unsigned int cpu, struct
}
}
-/**
- * get_tbufs - get pointer to and size of the trace buffers
- * @mfn: location to store mfn of the trace buffers to
- * @size: location to store the size of a trace buffer to
- *
- * Gets the machine address of the trace pointer area and the size of the
- * per CPU buffers.
- */
-void get_tbufs(unsigned long *mfn, unsigned long *size)
-{
- uint32_t size32;
- int xc_handle = xc_interface_open(); /* for accessing control interface */
-
- if (xc_tbuf_get_size(xc_handle, &size32) != 0)
- goto fail;
- *size = size32;
-
- if (xc_tbuf_get_mfn(xc_handle, mfn) != 0)
- goto fail;
+static void get_tbufs(unsigned long *mfn, unsigned long *size)
+{
+ int xc_handle = xc_interface_open();
+ int ret;
+
+ if ( xc_handle < 0 )
+ {
+ exit(EXIT_FAILURE);
+ }
+
+ ret = xc_tbuf_enable(xc_handle, DEFAULT_TBUF_SIZE, mfn, size);
+
+ if ( ret != 0 )
+ {
+ perror("Couldn't enable trace buffers");
+ exit(1);
+ }
xc_interface_close(xc_handle);
- return;
-
-fail:
- PERROR("Failure to get trace buffer pointer from Xen");
- exit(EXIT_FAILURE);
}
/**
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/xentrace/xentrace_format
--- a/tools/xentrace/xentrace_format Mon May 22 08:53:26 2006 -0600
+++ b/tools/xentrace/xentrace_format Mon May 22 14:13:38 2006 -0600
@@ -89,7 +89,7 @@ CPUREC = "I"
CPUREC = "I"
TRCREC = "QLLLLLL"
-last_tsc = [0,0,0,0,0,0,0,0]
+last_tsc = [0]
i=0
@@ -111,7 +111,9 @@ while not interrupted:
#print i, tsc
- if tsc < last_tsc[cpu]:
+ if cpu >= len(last_tsc):
+ last_tsc += [0] * (cpu - len(last_tsc) + 1)
+ elif tsc < last_tsc[cpu]:
print "TSC stepped backward cpu %d ! %d %d" %
(cpu,tsc,last_tsc[cpu])
last_tsc[cpu] = tsc
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/xm-test/configure.ac
--- a/tools/xm-test/configure.ac Mon May 22 08:53:26 2006 -0600
+++ b/tools/xm-test/configure.ac Mon May 22 14:13:38 2006 -0600
@@ -99,6 +99,7 @@ AC_CONFIG_FILES([
tests/block-list/Makefile
tests/block-create/Makefile
tests/block-destroy/Makefile
+ tests/block-integrity/Makefile
tests/console/Makefile
tests/create/Makefile
tests/destroy/Makefile
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/xm-test/ramdisk/bin/create_disk_image
--- a/tools/xm-test/ramdisk/bin/create_disk_image Mon May 22 08:53:26
2006 -0600
+++ b/tools/xm-test/ramdisk/bin/create_disk_image Mon May 22 14:13:38
2006 -0600
@@ -207,6 +207,13 @@ function dd_rootfs_to_image()
dd if="$ROOTFS" of="$LOOPP" > /dev/null 2>&1
if [ $? -ne 0 ]; then
die "Failed to dd $ROOTFS to $LOOPP."
+ fi
+
+ # Resize fs to use full partition
+ e2fsck -f $LOOPP
+ resize2fs $LOOPP
+ if [ $? -ne 0 ]; then
+ die "Failed to resize rootfs on $LOOPP."
fi
}
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/xm-test/tests/Makefile.am
--- a/tools/xm-test/tests/Makefile.am Mon May 22 08:53:26 2006 -0600
+++ b/tools/xm-test/tests/Makefile.am Mon May 22 14:13:38 2006 -0600
@@ -1,14 +1,15 @@ SUBDIRS = \
SUBDIRS = \
block-create \
- block-list \
- block-destroy \
+ block-list \
+ block-destroy \
+ block-integrity \
console \
create \
destroy \
dmesg \
domid \
domname \
- help \
+ help \
info \
list \
memmax \
diff -r fbf676a36ee4 -r 72c5d8206d48
tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py
--- a/tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py
Mon May 22 08:53:26 2006 -0600
+++ b/tools/xm-test/tests/enforce_dom0_cpus/01_enforce_dom0_cpus_basic_pos.py
Mon May 22 14:13:38 2006 -0600
@@ -4,20 +4,23 @@
# Authors: Dan Smith <danms@xxxxxxxxxx>
# Ryan Harper <ryanh@xxxxxxxxxx>
-# 1) Make sure we have a multi cpu system
+# 1) Make sure we have a multi cpu system and dom0 has at
+# least 2 vcpus online.
# 2) clone standard config (/etc/xen/xend-config.sxp)
# 3) modify clone with enforce_dom0_cpus=X
# 4) restart xend with modified config
# 5) check /proc/cpuinfo for cpu count
-# 6) check xm list -v to see that only 1 cpu is online for dom0
-# 7) Restart xend with default config
+# 6) check xm info 'VCPUs' field to see that only 'enforce_dom0_cpus'
+# number of cpus are online in dom0
+# 7) Restore initial dom0 vcpu state
+# 8) Restart xend with default config
import sys
import re
import time
import os
-# what value should dom0_cpus be enforced?
+# what value should dom0_cpus enforce?
enforce_dom0_cpus=1
from XmTestLib import *
@@ -25,12 +28,19 @@ check_status = 1
check_status = 1
max_tries = 10
-# 1) Make sure we have a multi cpu system
+# 1) Make sure we have a multi cpu system and dom0 has at least 2 vcpus online.
if smpConcurrencyLevel() <= 1:
print "*** NOTE: This machine does not have more than one physical"
print " or logical cpu. The vcpu-disable test cannot be run!"
SKIP("Host not capable of running test")
+
+# count number of online vcpus in dom0
+dom0_online_vcpus = int(getDomInfo("Domain-0", "VCPUs"))
+if dom0_online_vcpus <= 1:
+ print "*** NOTE: DOM0 needs at least 2 VCPUs online to run this test"
+ print " Please enable additional vcpus if possible via xm
vcpu-set"
+ SKIP("Host state not capable of running test")
# 2) clone standard config (/etc/xen/xend-config.sxp)
# 3) modify clone with enforce_dom0_cpus=1
@@ -55,36 +65,61 @@ if check_status and status != 0:
FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
# 5) check /proc/cpuinfo for cpu count
-cmd = "grep \"^processor\" /proc/cpuinfo | wc -l"
-status, output = traceCommand(cmd)
+
+# It takes some time for the CPU count to change, on multi-proc systems, so
check the number of procs in a loop for 20 seconds.
+#Sleep inside the loop for a second each time.
+timeout = 20
+starttime = time.time()
+while timeout + starttime > time.time():
+# Check /proc/cpuinfo
+ cmd = "grep \"^processor\" /proc/cpuinfo | wc -l"
+ status, output = traceCommand(cmd)
+ if check_status and status != 0:
+ os.unsetenv("XEND_CONFIG")
+ restartXend()
+ FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
+# Has it succeeded? If so, we can leave the loop
+ if output == str(enforce_dom0_cpus):
+ break
+# Sleep for 1 second before trying again
+ time.sleep(1)
+if output != str(enforce_dom0_cpus):
+ os.unsetenv("XEND_CONFIG")
+ restartXend()
+ FAIL("/proc/cpuinfo says xend didn't enforce dom0_cpus (%s !=
%s)"%(output,
+
enforce_dom0_cpus))
+
+# 6) count number of online cpus and see that it matches enforce value
+num_online = int(getDomInfo("Domain-0", "VCPUs"))
+if num_online != enforce_dom0_cpus:
+ os.unsetenv("XEND_CONFIG")
+ restartXend()
+ FAIL("xm says xend didn't enforce dom0_cpus (%s != %s)" %(num_online,
+
enforce_dom0_cpus))
+
+# 7) restore dead processors
+status, output = traceCommand("xm vcpu-set 0 %s"%(dom0_online_vcpus))
if check_status and status != 0:
os.unsetenv("XEND_CONFIG")
restartXend()
FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
-if output != str(enforce_dom0_cpus):
+# check restore worked
+# Since this also takes time, we will do it in a loop with a 20 second timeout.
+timeout=20
+starttime=time.time()
+while timeout + starttime > time.time():
+ num_online = int(getDomInfo("Domain-0", "VCPUs"))
+ if num_online == dom0_online_vcpus:
+ break
+ time.sleep(1)
+if num_online != dom0_online_vcpus:
os.unsetenv("XEND_CONFIG")
restartXend()
- FAIL("/proc/cpuinfo says xend didn't enforce dom0_cpus (%s != %s)"
%(output, enforce_dom0_cpus))
+ FAIL("failed to restore dom0's VCPUs")
-# 7) count number of online cpus and see that it matches enforce value
-dom0vcpus = getVcpuInfo("Domain-0")
-num_online = len(filter(lambda x: x >= 0, dom0vcpus.values()))
-if num_online != enforce_dom0_cpus:
- os.unsetenv("XEND_CONFIG")
- restartXend()
- FAIL("xm says xend didn't enforce dom0_cpus (%s != %s)" %(num_online,
enforce_dom0_cpus))
-# restore dead processors
-for (k,v) in zip(dom0vcpus.keys(),dom0vcpus.values()):
- if v == -1:
- status, output = traceCommand("xm vcpu-enable 0 %s"%(k))
- if check_status and status != 0:
- os.unsetenv("XEND_CONFIG")
- restartXend()
- FAIL("\"%s\" returned invalid %i != 0" %(cmd,status))
-
-# Restart xend with default config
+# 8) Restart xend with default config
os.unsetenv("XEND_CONFIG")
restartXend()
diff -r fbf676a36ee4 -r 72c5d8206d48
tools/xm-test/tests/network/03_network_local_tcp_pos.py
--- a/tools/xm-test/tests/network/03_network_local_tcp_pos.py Mon May 22
08:53:26 2006 -0600
+++ b/tools/xm-test/tests/network/03_network_local_tcp_pos.py Mon May 22
14:13:38 2006 -0600
@@ -44,7 +44,7 @@ try:
lofails=""
for size in trysizes:
out = console.runCmd("hping2 127.0.0.1 -E /dev/urandom -q -c 20 "
- + "--fast -d " + str(size))
+ + "--fast -d " + str(size) + " -N " + str(size))
if out["return"]:
lofails += " " + str(size)
@@ -54,7 +54,7 @@ try:
ip = netdev.getNetDevIP()
for size in trysizes:
out = console.runCmd("hping2 " + ip + " -E /dev/urandom -q -c 20 "
- + "--fast -d "+ str(size))
+ + "--fast -d "+ str(size) + " -N " + str(size))
if out["return"]:
eth0fails += " " + str(size)
except ConsoleError, e:
diff -r fbf676a36ee4 -r 72c5d8206d48
tools/xm-test/tests/network/04_network_local_udp_pos.py
--- a/tools/xm-test/tests/network/04_network_local_udp_pos.py Mon May 22
08:53:26 2006 -0600
+++ b/tools/xm-test/tests/network/04_network_local_udp_pos.py Mon May 22
14:13:38 2006 -0600
@@ -43,7 +43,7 @@ try:
lofails=""
for size in trysizes:
out = console.runCmd("hping2 127.0.0.1 -E /dev/urandom -2 -q -c 20 "
- + "--fast -d " + str(size))
+ + "--fast -d " + str(size) + " -N " + str(size))
if out["return"]:
lofails += " " + str(size)
print out["output"]
@@ -54,7 +54,7 @@ try:
ip = netdev.getNetDevIP()
for size in trysizes:
out = console.runCmd("hping2 " + ip + " -E /dev/urandom -2 -q -c 20 "
- + "--fast -d " + str(size))
+ + "--fast -d " + str(size) + " -N " + str(size))
if out["return"]:
eth0fails += " " + str(size)
print out["output"]
diff -r fbf676a36ee4 -r 72c5d8206d48
tools/xm-test/tests/network/06_network_dom0_tcp_pos.py
--- a/tools/xm-test/tests/network/06_network_dom0_tcp_pos.py Mon May 22
08:53:26 2006 -0600
+++ b/tools/xm-test/tests/network/06_network_dom0_tcp_pos.py Mon May 22
14:13:38 2006 -0600
@@ -44,7 +44,7 @@ try:
dom0ip = netdev.getDom0AliasIP()
for size in trysizes:
out = console.runCmd("hping2 " + dom0ip + " -E /dev/urandom -q -c 20 "
- + "--fast -d " + str(size))
+ + "--fast -d " + str(size) + " -N " + str(size))
if out["return"]:
fails += " " + str(size)
print out["output"]
diff -r fbf676a36ee4 -r 72c5d8206d48
tools/xm-test/tests/network/07_network_dom0_udp_pos.py
--- a/tools/xm-test/tests/network/07_network_dom0_udp_pos.py Mon May 22
08:53:26 2006 -0600
+++ b/tools/xm-test/tests/network/07_network_dom0_udp_pos.py Mon May 22
14:13:38 2006 -0600
@@ -43,7 +43,7 @@ try:
dom0ip = netdev.getDom0AliasIP()
for size in trysizes:
out = console.runCmd("hping2 " + dom0ip + " -E /dev/urandom -2 -q -c
20"
- + " --fast -d " + str(size))
+ + " --fast -d " + str(size) + " -N " + str(size))
if out["return"]:
fails += " " + str(size)
print out["output"]
diff -r fbf676a36ee4 -r 72c5d8206d48
tools/xm-test/tests/network/12_network_domU_tcp_pos.py
--- a/tools/xm-test/tests/network/12_network_domU_tcp_pos.py Mon May 22
08:53:26 2006 -0600
+++ b/tools/xm-test/tests/network/12_network_domU_tcp_pos.py Mon May 22
14:13:38 2006 -0600
@@ -50,7 +50,7 @@ try:
ip2 = dst_netdev.getNetDevIP()
for size in pingsizes:
out = src_console.runCmd("hping2 " + ip2 + " -E /dev/urandom -q -c 20 "
- + "--fast -d " + str(size))
+ + "--fast -d " + str(size) + " -N " + str(size))
if out["return"]:
fails += " " + str(size)
print out["output"]
diff -r fbf676a36ee4 -r 72c5d8206d48
tools/xm-test/tests/network/13_network_domU_udp_pos.py
--- a/tools/xm-test/tests/network/13_network_domU_udp_pos.py Mon May 22
08:53:26 2006 -0600
+++ b/tools/xm-test/tests/network/13_network_domU_udp_pos.py Mon May 22
14:13:38 2006 -0600
@@ -50,7 +50,7 @@ try:
ip2 = dst_netdev.getNetDevIP()
for size in pingsizes:
out = src_console.runCmd("hping2 " + ip2 + " -E /dev/urandom -2 -q "
- + "-c 20 --fast -d " + str(size))
+ + "-c 20 --fast -d " + str(size) + " -N " + str(size))
if out["return"]:
fails += " " + str(size)
print out["output"]
diff -r fbf676a36ee4 -r 72c5d8206d48
tools/xm-test/tests/vtpm/04_vtpm-loc_migr.py
--- a/tools/xm-test/tests/vtpm/04_vtpm-loc_migr.py Mon May 22 08:53:26
2006 -0600
+++ b/tools/xm-test/tests/vtpm/04_vtpm-loc_migr.py Mon May 22 14:13:38
2006 -0600
@@ -6,6 +6,7 @@
# Positive Test: create domain with virtual TPM attached at build time,
# check list of pcrs; locally migrate the domain and
# check list of pcrs again
+# This test does local live migration.
from XmTestLib import *
from vtpm_utils import *
@@ -50,40 +51,44 @@ domain.closeConsole()
old_domid = domid(domName)
-try:
- status, ouptut = traceCommand("xm migrate -l %s localhost" %
- domName,
- timeout=90)
-except TimeoutError, e:
- saveLog(consoleHistory)
- vtpm_cleanup(domName)
- FAIL(str(e))
+loop = 0
+while loop < 3:
+ try:
+ status, ouptut = traceCommand("xm migrate -l %s localhost" %
+ domName,
+ 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?")
+ if status != 0:
+ saveLog(consoleHistory)
+ vtpm_cleanup(domName)
+ FAIL("xm migrate did not succeed. External device migration
activated?")
-domName = domain.getName()
-new_domid = domid(domName)
+ domName = domain.getName()
+ new_domid = domid(domName)
-if (old_domid == new_domid):
- vtpm_cleanup(domName)
- FAIL("xm migrate failed, domain id is still %s" % old_domid)
+ 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:
+ console = domain.getConsole()
+ except ConsoleError, e:
+ vtpm_cleanup(domName)
+ FAIL(str(e))
-try:
- run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
-except ConsoleError, e:
- saveLog(console.getHistory())
- vtpm_cleanup(domName)
- FAIL(str(e))
+ try:
+ run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
+ except ConsoleError, e:
+ saveLog(console.getHistory())
+ vtpm_cleanup(domName)
+ FAIL(str(e))
+ loop += 1
domain.closeConsole()
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/xm-test/tests/vtpm/Makefile.am
--- a/tools/xm-test/tests/vtpm/Makefile.am Mon May 22 08:53:26 2006 -0600
+++ b/tools/xm-test/tests/vtpm/Makefile.am Mon May 22 14:13:38 2006 -0600
@@ -3,7 +3,8 @@ TESTS = 01_vtpm-list_pos.test \
TESTS = 01_vtpm-list_pos.test \
02_vtpm-cat_pcrs.test \
03_vtpm-susp_res.test \
- 04_vtpm-loc_migr.test
+ 04_vtpm-loc_migr.test \
+ 05_vtpm-loc_migr.test
XFAIL_TESTS =
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/arch/x86/dom0_ops.c
--- a/xen/arch/x86/dom0_ops.c Mon May 22 08:53:26 2006 -0600
+++ b/xen/arch/x86/dom0_ops.c Mon May 22 14:13:38 2006 -0600
@@ -404,27 +404,6 @@ long arch_do_dom0_op(struct dom0_op *op,
}
break;
- case DOM0_PHYSICAL_MEMORY_MAP:
- {
- struct dom0_memory_map_entry entry;
- int i;
-
- for ( i = 0; i < e820.nr_map; i++ )
- {
- if ( i >= op->u.physical_memory_map.max_map_entries )
- break;
- entry.start = e820.map[i].addr;
- entry.end = e820.map[i].addr + e820.map[i].size;
- entry.is_ram = (e820.map[i].type == E820_RAM);
- (void)copy_to_guest_offset(
- op->u.physical_memory_map.memory_map, i, &entry, 1);
- }
-
- op->u.physical_memory_map.nr_map_entries = i;
- (void)copy_to_guest(u_dom0_op, op, 1);
- }
- break;
-
case DOM0_HYPERCALL_INIT:
{
struct domain *d;
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c Mon May 22 08:53:26 2006 -0600
+++ b/xen/arch/x86/domain.c Mon May 22 14:13:38 2006 -0600
@@ -286,6 +286,11 @@ int arch_set_info_guest(
v->arch.flags |= TF_kernel_mode;
memcpy(&v->arch.guest_context, c, sizeof(*c));
+
+ /* Only CR0.TS is modifiable by guest or admin. */
+ v->arch.guest_context.ctrlreg[0] &= X86_CR0_TS;
+ v->arch.guest_context.ctrlreg[0] |= read_cr0() & ~X86_CR0_TS;
+
init_int80_direct_trap(v);
if ( !(c->flags & VGCF_HVM_GUEST) )
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c Mon May 22 08:53:26 2006 -0600
+++ b/xen/arch/x86/hvm/hvm.c Mon May 22 14:13:38 2006 -0600
@@ -189,7 +189,11 @@ void hvm_setup_platform(struct domain* d
if ( !hvm_guest(current) || (current->vcpu_id != 0) )
return;
- shadow_direct_map_init(d);
+ if ( shadow_direct_map_init(d) == 0 )
+ {
+ printk("Can not allocate shadow direct map for HVM domain.\n");
+ domain_crash_synchronous();
+ }
hvm_map_io_shared_page(d);
hvm_get_info(d);
@@ -240,15 +244,18 @@ int cpu_get_interrupt(struct vcpu *v, in
{
int intno;
struct hvm_virpic *s = &v->domain->arch.hvm_domain.vpic;
+ unsigned long flags;
if ( (intno = cpu_get_apic_interrupt(v, type)) != -1 ) {
/* set irq request if a PIC irq is still pending */
/* XXX: improve that */
+ spin_lock_irqsave(&s->lock, flags);
pic_update_irq(s);
+ spin_unlock_irqrestore(&s->lock, flags);
return intno;
}
/* read the irq from the PIC */
- if ( (intno = cpu_get_pic_interrupt(v, type)) != -1 )
+ if ( v->vcpu_id == 0 && (intno = cpu_get_pic_interrupt(v, type)) != -1 )
return intno;
return -1;
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/arch/x86/hvm/i8259.c
--- a/xen/arch/x86/hvm/i8259.c Mon May 22 08:53:26 2006 -0600
+++ b/xen/arch/x86/hvm/i8259.c Mon May 22 14:13:38 2006 -0600
@@ -35,9 +35,13 @@
#include <asm/current.h>
/* set irq level. If an edge is detected, then the IRR is set to 1 */
+/* Caller must hold vpic lock */
static inline void pic_set_irq1(PicState *s, int irq, int level)
{
int mask;
+
+ BUG_ON(!spin_is_locked(&s->pics_state->lock));
+
mask = 1 << irq;
if (s->elcr & mask) {
/* level triggered */
@@ -63,9 +67,13 @@ static inline void pic_set_irq1(PicState
/* return the highest priority found in mask (highest = smallest
number). Return 8 if no irq */
+/* Caller must hold vpic lock */
static inline int get_priority(PicState *s, int mask)
{
int priority;
+
+ BUG_ON(!spin_is_locked(&s->pics_state->lock));
+
if (mask == 0)
return 8;
priority = 0;
@@ -75,9 +83,12 @@ static inline int get_priority(PicState
}
/* return the pic wanted interrupt. return -1 if none */
+/* Caller must hold vpic lock */
static int pic_get_irq(PicState *s)
{
int mask, cur_priority, priority;
+
+ BUG_ON(!spin_is_locked(&s->pics_state->lock));
mask = s->irr & ~s->imr;
priority = get_priority(s, mask);
@@ -101,9 +112,12 @@ static int pic_get_irq(PicState *s)
/* raise irq to CPU if necessary. must be called every time the active
irq may change */
/* XXX: should not export it, but it is needed for an APIC kludge */
+/* Caller must hold vpic lock */
void pic_update_irq(struct hvm_virpic *s)
{
int irq2, irq;
+
+ BUG_ON(!spin_is_locked(&s->lock));
/* first look at slave pic */
irq2 = pic_get_irq(&s->pics[1]);
@@ -122,29 +136,40 @@ void pic_set_irq_new(void *opaque, int i
void pic_set_irq_new(void *opaque, int irq, int level)
{
struct hvm_virpic *s = opaque;
-
+ unsigned long flags;
+
+ spin_lock_irqsave(&s->lock, flags);
hvm_vioapic_set_irq(current->domain, irq, level);
pic_set_irq1(&s->pics[irq >> 3], irq & 7, level);
/* used for IOAPIC irqs */
if (s->alt_irq_func)
s->alt_irq_func(s->alt_irq_opaque, irq, level);
pic_update_irq(s);
+ spin_unlock_irqrestore(&s->lock, flags);
}
void do_pic_irqs (struct hvm_virpic *s, uint16_t irqs)
{
+ unsigned long flags;
+
+ spin_lock_irqsave(&s->lock, flags);
s->pics[1].irr |= (uint8_t)(irqs >> 8);
s->pics[0].irr |= (uint8_t) irqs;
hvm_vioapic_do_irqs(current->domain, irqs);
pic_update_irq(s);
+ spin_unlock_irqrestore(&s->lock, flags);
}
void do_pic_irqs_clear (struct hvm_virpic *s, uint16_t irqs)
{
+ unsigned long flags;
+
+ spin_lock_irqsave(&s->lock, flags);
s->pics[1].irr &= ~(uint8_t)(irqs >> 8);
s->pics[0].irr &= ~(uint8_t) irqs;
hvm_vioapic_do_irqs_clear(current->domain, irqs);
pic_update_irq(s);
+ spin_unlock_irqrestore(&s->lock, flags);
}
/* obsolete function */
@@ -154,8 +179,11 @@ void pic_set_irq(struct hvm_virpic *isa_
}
/* acknowledge interrupt 'irq' */
+/* Caller must hold vpic lock */
static inline void pic_intack(PicState *s, int irq)
{
+ BUG_ON(!spin_is_locked(&s->pics_state->lock));
+
if (s->auto_eoi) {
if (s->rotate_on_auto_eoi)
s->priority_add = (irq + 1) & 7;
@@ -170,7 +198,9 @@ int pic_read_irq(struct hvm_virpic *s)
int pic_read_irq(struct hvm_virpic *s)
{
int irq, irq2, intno;
-
+ unsigned long flags;
+
+ spin_lock_irqsave(&s->lock, flags);
irq = pic_get_irq(&s->pics[0]);
if (irq >= 0) {
pic_intack(&s->pics[0], irq);
@@ -194,13 +224,17 @@ int pic_read_irq(struct hvm_virpic *s)
intno = s->pics[0].irq_base + irq;
}
pic_update_irq(s);
+ spin_unlock_irqrestore(&s->lock, flags);
return intno;
}
+/* Caller must hold vpic lock */
static void update_shared_irr(struct hvm_virpic *s, PicState *c)
{
uint8_t *pl, *pe;
+
+ BUG_ON(!spin_is_locked(&s->lock));
get_sp(current->domain)->sp_global.pic_elcr =
s->pics[0].elcr | ((u16)s->pics[1].elcr << 8);
@@ -216,9 +250,12 @@ static void update_shared_irr(struct hvm
}
}
+/* Caller must hold vpic lock */
static void pic_reset(void *opaque)
{
PicState *s = opaque;
+
+ BUG_ON(!spin_is_locked(&s->pics_state->lock));
s->last_irr = 0;
s->irr = 0;
@@ -237,10 +274,13 @@ static void pic_reset(void *opaque)
s->elcr = 0;
}
+/* Caller must hold vpic lock */
static void pic_ioport_write(void *opaque, uint32_t addr, uint32_t val)
{
PicState *s = opaque;
int priority, cmd, irq;
+
+ BUG_ON(!spin_is_locked(&s->pics_state->lock));
addr &= 1;
if (addr == 0) {
@@ -328,9 +368,12 @@ static void pic_ioport_write(void *opaqu
}
}
+/* Caller must hold vpic lock */
static uint32_t pic_poll_read (PicState *s, uint32_t addr1)
{
int ret;
+
+ BUG_ON(!spin_is_locked(&s->pics_state->lock));
ret = pic_get_irq(s);
if (ret >= 0) {
@@ -350,11 +393,14 @@ static uint32_t pic_poll_read (PicState
return ret;
}
+/* Caller must hold vpic lock */
static uint32_t pic_ioport_read(void *opaque, uint32_t addr1)
{
PicState *s = opaque;
unsigned int addr;
int ret;
+
+ BUG_ON(!spin_is_locked(&s->pics_state->lock));
addr = addr1;
addr &= 1;
@@ -375,23 +421,30 @@ static uint32_t pic_ioport_read(void *op
}
/* memory mapped interrupt status */
-/* XXX: may be the same than pic_read_irq() */
+/* XXX: may be the same than pic_read_rq() */
uint32_t pic_intack_read(struct hvm_virpic *s)
{
int ret;
-
+ unsigned long flags;
+
+ spin_lock_irqsave(&s->lock, flags);
ret = pic_poll_read(&s->pics[0], 0x00);
if (ret == 2)
ret = pic_poll_read(&s->pics[1], 0x80) + 8;
/* Prepare for ISR read */
s->pics[0].read_reg_select = 1;
+ spin_unlock_irqrestore(&s->lock, flags);
return ret;
}
static void elcr_ioport_write(void *opaque, uint32_t addr, uint32_t val)
+/* Caller must hold vpic lock */
{
PicState *s = opaque;
+
+ BUG_ON(!spin_is_locked(&s->pics_state->lock));
+
s->elcr = val & s->elcr_mask;
}
@@ -402,23 +455,31 @@ static uint32_t elcr_ioport_read(void *o
}
/* XXX: add generic master/slave system */
+/* Caller must hold vpic lock */
static void pic_init1(int io_addr, int elcr_addr, PicState *s)
{
+ BUG_ON(!spin_is_locked(&s->pics_state->lock));
+
pic_reset(s);
}
void pic_init(struct hvm_virpic *s, void (*irq_request)(void *, int),
void *irq_request_opaque)
{
+ unsigned long flags;
+
memset(s, 0, sizeof(*s));
+ spin_lock_init(&s->lock);
+ s->pics[0].pics_state = s;
+ s->pics[1].pics_state = s;
+ spin_lock_irqsave(&s->lock, flags);
pic_init1(0x20, 0x4d0, &s->pics[0]);
pic_init1(0xa0, 0x4d1, &s->pics[1]);
+ spin_unlock_irqrestore(&s->lock, flags);
s->pics[0].elcr_mask = 0xf8;
s->pics[1].elcr_mask = 0xde;
s->irq_request = irq_request;
s->irq_request_opaque = irq_request_opaque;
- s->pics[0].pics_state = s;
- s->pics[1].pics_state = s;
return;
}
@@ -426,8 +487,12 @@ void pic_set_alt_irq_func(struct hvm_vir
void (*alt_irq_func)(void *, int, int),
void *alt_irq_opaque)
{
+ unsigned long flags;
+
+ spin_lock_irqsave(&s->lock, flags);
s->alt_irq_func = alt_irq_func;
s->alt_irq_opaque = alt_irq_opaque;
+ spin_unlock_irqrestore(&s->lock, flags);
}
static int intercept_pic_io(ioreq_t *p)
@@ -435,6 +500,7 @@ static int intercept_pic_io(ioreq_t *p)
struct hvm_virpic *pic;
struct vcpu *v = current;
uint32_t data;
+ unsigned long flags;
if ( p->size != 1 || p->count != 1) {
printk("PIC_IO wrong access size %d!\n", (int)p->size);
@@ -446,12 +512,16 @@ static int intercept_pic_io(ioreq_t *p)
hvm_copy(&data, (unsigned long)p->u.pdata, p->size, HVM_COPY_IN);
else
data = p->u.data;
+ spin_lock_irqsave(&pic->lock, flags);
pic_ioport_write((void*)&pic->pics[p->addr>>7],
(uint32_t) p->addr, (uint32_t) (data & 0xff));
+ spin_unlock_irqrestore(&pic->lock, flags);
}
else {
+ spin_lock_irqsave(&pic->lock, flags);
data = pic_ioport_read(
(void*)&pic->pics[p->addr>>7], (uint32_t) p->addr);
+ spin_unlock_irqrestore(&pic->lock, flags);
if(p->pdata_valid)
hvm_copy(&data, (unsigned long)p->u.pdata, p->size, HVM_COPY_OUT);
else
@@ -465,6 +535,7 @@ static int intercept_elcr_io(ioreq_t *p)
struct hvm_virpic *s;
struct vcpu *v = current;
uint32_t data;
+ unsigned long flags;
if ( p->size != 1 || p->count != 1 ) {
printk("PIC_IO wrong access size %d!\n", (int)p->size);
@@ -477,10 +548,12 @@ static int intercept_elcr_io(ioreq_t *p)
hvm_copy(&data, (unsigned long)p->u.pdata, p->size, HVM_COPY_IN);
else
data = p->u.data;
+ spin_lock_irqsave(&s->lock, flags);
elcr_ioport_write((void*)&s->pics[p->addr&1],
(uint32_t) p->addr, (uint32_t)( data & 0xff));
get_sp(current->domain)->sp_global.pic_elcr =
s->pics[0].elcr | ((u16)s->pics[1].elcr << 8);
+ spin_unlock_irqrestore(&s->lock, flags);
}
else {
data = (u64) elcr_ioport_read(
@@ -512,10 +585,9 @@ int cpu_get_pic_interrupt(struct vcpu *v
if ( !vlapic_accept_pic_intr(v) )
return -1;
- if ( !plat->interrupt_request )
+ if (cmpxchg(&plat->interrupt_request, 1, 0) != 1)
return -1;
- plat->interrupt_request = 0;
/* read the irq from the PIC */
intno = pic_read_irq(s);
*type = VLAPIC_DELIV_MODE_EXT;
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/arch/x86/hvm/platform.c
--- a/xen/arch/x86/hvm/platform.c Mon May 22 08:53:26 2006 -0600
+++ b/xen/arch/x86/hvm/platform.c Mon May 22 14:13:38 2006 -0600
@@ -865,7 +865,7 @@ void handle_mmio(unsigned long va, unsig
* copy ourself. After this copy succeeds, "rep movs" is executed
* again.
*/
- if ((addr & PAGE_MASK) != ((addr + size - 1) & PAGE_MASK)) {
+ if ((addr & PAGE_MASK) != ((addr + sign * (size - 1)) & PAGE_MASK)) {
unsigned long value = 0;
mmio_opp->flags |= OVERLAP;
@@ -876,7 +876,7 @@ void handle_mmio(unsigned long va, unsig
hvm_copy(&value, addr, size, HVM_COPY_IN);
send_mmio_req(IOREQ_TYPE_COPY, gpa, 1, size, value, dir, 0);
} else {
- if ((addr & PAGE_MASK) != ((addr + count * size - 1) & PAGE_MASK))
{
+ if ((addr & PAGE_MASK) != ((addr + sign * (count * size - 1)) &
PAGE_MASK)) {
regs->eip -= inst_len; /* do not advance %eip */
if (sign > 0)
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/arch/x86/hvm/svm/intr.c
--- a/xen/arch/x86/hvm/svm/intr.c Mon May 22 08:53:26 2006 -0600
+++ b/xen/arch/x86/hvm/svm/intr.c Mon May 22 14:13:38 2006 -0600
@@ -132,17 +132,13 @@ asmlinkage void svm_intr_assist(void)
ASSERT(vmcb);
/* Check if an Injection is active */
- if (v->arch.hvm_svm.injecting_event) {
/* Previous Interrupt delivery caused this Intercept? */
if (vmcb->exitintinfo.fields.v && (vmcb->exitintinfo.fields.type == 0))
{
v->arch.hvm_svm.saved_irq_vector = vmcb->exitintinfo.fields.vector;
// printk("Injecting PF#: saving IRQ from ExitInfo\n");
vmcb->exitintinfo.bytes = 0;
-
- /* bail out, we won't be injecting an interrupt this time */
- return;
+ re_injecting = 1;
}
- }
/* Guest's interrputs masked? */
rflags = vmcb->rflags;
@@ -151,16 +147,9 @@ asmlinkage void svm_intr_assist(void)
/* bail out, we won't be injecting an interrupt this time */
return;
}
-
- /* Interrupt delivery caused an Intercept? */
- if (vmcb->exitintinfo.fields.v && (vmcb->exitintinfo.fields.type == 0)) {
-// printk("Re-injecting IRQ from ExitInfo\n");
- intr_vector = vmcb->exitintinfo.fields.vector;
- vmcb->exitintinfo.bytes = 0;
- re_injecting = 1;
- }
+
/* Previous interrupt still pending? */
- else if (vmcb->vintr.fields.irq) {
+ if (vmcb->vintr.fields.irq) {
// printk("Re-injecting IRQ from Vintr\n");
intr_vector = vmcb->vintr.fields.vector;
vmcb->vintr.bytes = 0;
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c Mon May 22 08:53:26 2006 -0600
+++ b/xen/arch/x86/hvm/svm/svm.c Mon May 22 14:13:38 2006 -0600
@@ -82,9 +82,11 @@ void svm_dump_regs(const char *from, str
static void svm_relinquish_guest_resources(struct domain *d);
-/* Host save area */
-struct host_save_area *host_save_area[ NR_CPUS ] = {0};
-static struct asid_pool ASIDpool[NR_CPUS];
+
+extern void set_hsa_to_guest( struct arch_svm_struct *arch_svm );
+
+/* Host save area and ASID glogal data */
+struct svm_percore_globals svm_globals[NR_CPUS];
/*
* Initializes the POOL of ASID used by the guests per core.
@@ -92,15 +94,15 @@ void asidpool_init( int core )
void asidpool_init( int core )
{
int i;
- ASIDpool[core].asid_lock = SPIN_LOCK_UNLOCKED;
- spin_lock(&ASIDpool[core].asid_lock);
+ svm_globals[core].ASIDpool.asid_lock = SPIN_LOCK_UNLOCKED;
+ spin_lock(&svm_globals[core].ASIDpool.asid_lock);
/* Host ASID is always in use */
- ASIDpool[core].asid[INITIAL_ASID] = ASID_INUSE;
+ svm_globals[core].ASIDpool.asid[INITIAL_ASID] = ASID_INUSE;
for( i=1; i<ASID_MAX; i++ )
{
- ASIDpool[core].asid[i] = ASID_AVAILABLE;
- }
- spin_unlock(&ASIDpool[core].asid_lock);
+ svm_globals[core].ASIDpool.asid[i] = ASID_AVAILABLE;
+ }
+ spin_unlock(&svm_globals[core].ASIDpool.asid_lock);
}
@@ -110,10 +112,10 @@ static int asidpool_fetch_next( struct v
int i;
for( i = 1; i < ASID_MAX; i++ )
{
- if( ASIDpool[core].asid[i] == ASID_AVAILABLE )
+ if( svm_globals[core].ASIDpool.asid[i] == ASID_AVAILABLE )
{
vmcb->guest_asid = i;
- ASIDpool[core].asid[i] = ASID_INUSE;
+ svm_globals[core].ASIDpool.asid[i] = ASID_INUSE;
return i;
}
}
@@ -138,42 +140,42 @@ int asidpool_assign_next( struct vmcb_st
int res = 1;
static unsigned long cnt=0;
- spin_lock(&ASIDpool[oldcore].asid_lock);
+ spin_lock(&svm_globals[oldcore].ASIDpool.asid_lock);
if( retire_current && vmcb->guest_asid ) {
- ASIDpool[oldcore].asid[ vmcb->guest_asid & (ASID_MAX-1) ] =
ASID_RETIRED;
- }
- spin_unlock(&ASIDpool[oldcore].asid_lock);
- spin_lock(&ASIDpool[newcore].asid_lock);
+ svm_globals[oldcore].ASIDpool.asid[ vmcb->guest_asid & (ASID_MAX-1) ] =
ASID_RETIRED;
+ }
+ spin_unlock(&svm_globals[oldcore].ASIDpool.asid_lock);
+ spin_lock(&svm_globals[newcore].ASIDpool.asid_lock);
if( asidpool_fetch_next( vmcb, newcore ) < 0 ) {
if (svm_dbg_on)
printk( "SVM: tlb(%ld)\n", cnt++ );
/* FLUSH the TLB and all retired slots are made available */
vmcb->tlb_control = 1;
for( i = 1; i < ASID_MAX; i++ ) {
- if( ASIDpool[newcore].asid[i] == ASID_RETIRED ) {
- ASIDpool[newcore].asid[i] = ASID_AVAILABLE;
+ if( svm_globals[newcore].ASIDpool.asid[i] == ASID_RETIRED ) {
+ svm_globals[newcore].ASIDpool.asid[i] = ASID_AVAILABLE;
}
}
/* Get the First slot available */
res = asidpool_fetch_next( vmcb, newcore ) > 0;
}
- spin_unlock(&ASIDpool[newcore].asid_lock);
+ spin_unlock(&svm_globals[newcore].ASIDpool.asid_lock);
return res;
}
void asidpool_retire( struct vmcb_struct *vmcb, int core )
{
- spin_lock(&ASIDpool[core].asid_lock);
+ spin_lock(&svm_globals[core].ASIDpool.asid_lock);
if( vmcb->guest_asid ) {
- ASIDpool[core].asid[ vmcb->guest_asid & (ASID_MAX-1) ] = ASID_RETIRED;
+ svm_globals[core].ASIDpool.asid[ vmcb->guest_asid & (ASID_MAX-1) ] =
ASID_RETIRED;
}
- spin_unlock(&ASIDpool[core].asid_lock);
-}
-
-static inline void svm_inject_exception(struct vmcb_struct *vmcb,
- int trap, int ev, int error_code)
+ spin_unlock(&svm_globals[core].ASIDpool.asid_lock);
+}
+
+static inline 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;
event.bytes = 0;
event.fields.v = 1;
@@ -198,8 +200,13 @@ void stop_svm(void)
wrmsr(MSR_EFER, eax, edx);
/* release the HSA */
- free_host_save_area( host_save_area[ cpu ] );
- host_save_area[ cpu ] = NULL;
+ free_host_save_area( svm_globals[cpu].hsa );
+ free_host_save_area( svm_globals[cpu].scratch_hsa );
+ svm_globals[cpu].hsa = NULL;
+ svm_globals[cpu].hsa_pa = 0;
+ svm_globals[cpu].scratch_hsa = NULL;
+ svm_globals[cpu].scratch_hsa_pa = 0;
+ wrmsr(MSR_K8_VM_HSAVE_PA, 0, 0 );
printk("AMD SVM Extension is disabled.\n");
}
@@ -329,7 +336,7 @@ static inline int long_mode_do_msr_write
if ( msr_content & ~(EFER_LME | EFER_LMA | EFER_NX | EFER_SCE) )
{
printk("trying to set reserved bit in EFER\n");
- svm_inject_exception(vmcb, TRAP_gp_fault, 1, 0);
+ svm_inject_exception(vc, TRAP_gp_fault, 1, 0);
return 0;
}
@@ -343,7 +350,7 @@ static inline int long_mode_do_msr_write
{
printk("trying to set LME bit when "
"in paging mode or PAE bit is not set\n");
- svm_inject_exception(vmcb, TRAP_gp_fault, 1, 0);
+ svm_inject_exception(vc, TRAP_gp_fault, 1, 0);
return 0;
}
set_bit(SVM_CPU_STATE_LME_ENABLED, &vc->arch.hvm_svm.cpu_state);
@@ -367,7 +374,7 @@ static inline int long_mode_do_msr_write
if (!IS_CANO_ADDRESS(msr_content))
{
HVM_DBG_LOG(DBG_LEVEL_1, "Not cano address of msr write\n");
- svm_inject_exception(vmcb, TRAP_gp_fault, 1, 0);
+ svm_inject_exception(vc, TRAP_gp_fault, 1, 0);
}
if (regs->ecx == MSR_FS_BASE)
@@ -451,20 +458,26 @@ int start_svm(void)
if (!(test_bit(X86_FEATURE_SVME, &boot_cpu_data.x86_capability)))
return 0;
+ svm_globals[cpu].hsa = alloc_host_save_area();
+ if (! svm_globals[cpu].hsa)
+ return 0;
rdmsr(MSR_EFER, eax, edx);
eax |= EFER_SVME;
wrmsr(MSR_EFER, eax, edx);
- asidpool_init(smp_processor_id());
+ asidpool_init( cpu );
printk("AMD SVM Extension is enabled for cpu %d.\n", cpu );
/* Initialize the HSA for this core */
- host_save_area[ cpu ] = alloc_host_save_area();
- phys_hsa = (u64) virt_to_maddr( host_save_area[ cpu ] );
+ phys_hsa = (u64) virt_to_maddr( svm_globals[cpu].hsa );
phys_hsa_lo = (u32) phys_hsa;
phys_hsa_hi = (u32) (phys_hsa >> 32);
wrmsr(MSR_K8_VM_HSAVE_PA, phys_hsa_lo, phys_hsa_hi);
-
+ svm_globals[cpu].hsa_pa = phys_hsa;
+
+ svm_globals[cpu].scratch_hsa = alloc_host_save_area();
+ svm_globals[cpu].scratch_hsa_pa = (u64)virt_to_maddr(
svm_globals[cpu].scratch_hsa );
+
/* Setup HVM interfaces */
hvm_funcs.disable = stop_svm;
@@ -546,7 +559,6 @@ static inline int svm_do_debugout(unsign
return 1;
}
-
void save_svm_cpu_user_regs(struct vcpu *v, struct cpu_user_regs *ctxt)
{
struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
@@ -577,8 +589,6 @@ void svm_store_cpu_user_regs(struct cpu_
regs->ds = vmcb->ds.sel;
regs->es = vmcb->es.sel;
regs->ss = vmcb->ss.sel;
- regs->fs = vmcb->fs.sel;
- regs->gs = vmcb->gs.sel;
}
/* XXX Use svm_load_cpu_guest_regs instead */
@@ -594,12 +604,6 @@ void svm_load_cpu_user_regs(struct vcpu
vmcb->rflags = regs->eflags;
vmcb->cs.sel = regs->cs;
vmcb->rip = regs->eip;
-
- vmcb->ds.sel = regs->ds;
- vmcb->es.sel = regs->es;
- vmcb->fs.sel = regs->fs;
- vmcb->gs.sel = regs->gs;
-
if (regs->eflags & EF_TF)
*intercepts |= EXCEPTION_BITMAP_DB;
else
@@ -897,10 +901,9 @@ static void svm_do_general_protection_fa
(unsigned long)regs->eax, (unsigned long)regs->ebx,
(unsigned long)regs->ecx, (unsigned long)regs->edx,
(unsigned long)regs->esi, (unsigned long)regs->edi);
-
-
+
/* Reflect it back into the guest */
- svm_inject_exception(vmcb, TRAP_gp_fault, 1, error_code);
+ svm_inject_exception(v, TRAP_gp_fault, 1, error_code);
}
/* Reserved bits: [31:14], [12:1] */
@@ -1118,19 +1121,17 @@ static void svm_dr_access (struct vcpu *
}
-static unsigned int check_for_null_selector(struct vmcb_struct *vmcb,
- unsigned int dir, unsigned long *base, unsigned int real)
-
+static void svm_get_prefix_info(struct vmcb_struct *vmcb,
+ unsigned int dir, segment_selector_t **seg, unsigned int *asize)
{
unsigned char inst[MAX_INST_LEN];
- segment_selector_t seg;
int i;
memset(inst, 0, MAX_INST_LEN);
if (inst_copy_from_guest(inst, svm_rip2pointer(vmcb), sizeof(inst))
!= MAX_INST_LEN)
{
- printk("check_for_null_selector: get guest instruction failed\n");
+ printk("%s: get guest instruction failed\n", __func__);
domain_crash_synchronous();
}
@@ -1142,7 +1143,6 @@ static unsigned int check_for_null_selec
case 0xf2: /* REPNZ */
case 0xf0: /* LOCK */
case 0x66: /* data32 */
- case 0x67: /* addr32 */
#if __x86_64__
/* REX prefixes */
case 0x40:
@@ -1164,89 +1164,134 @@ static unsigned int check_for_null_selec
case 0x4f:
#endif
continue;
+ case 0x67: /* addr32 */
+ *asize ^= 48; /* Switch 16/32 bits */
+ continue;
case 0x2e: /* CS */
- seg = vmcb->cs;
+ *seg = &vmcb->cs;
+ continue;
+ case 0x36: /* SS */
+ *seg = &vmcb->ss;
+ continue;
+ case 0x26: /* ES */
+ *seg = &vmcb->es;
+ continue;
+ case 0x64: /* FS */
+ *seg = &vmcb->fs;
+ continue;
+ case 0x65: /* GS */
+ *seg = &vmcb->gs;
+ continue;
+ case 0x3e: /* DS */
+ *seg = &vmcb->ds;
+ continue;
+ default:
break;
- case 0x36: /* SS */
- seg = vmcb->ss;
- break;
- case 0x26: /* ES */
- seg = vmcb->es;
- break;
- case 0x64: /* FS */
- seg = vmcb->fs;
- break;
- case 0x65: /* GS */
- seg = vmcb->gs;
- break;
- case 0x3e: /* DS */
- /* FALLTHROUGH */
- seg = vmcb->ds;
- break;
- default:
- if (dir == IOREQ_READ) /* IN/INS instruction? */
- seg = vmcb->es;
- else
- seg = vmcb->ds;
- }
-
- if (base)
- *base = seg.base;
-
- return seg.attributes.fields.p;
- }
-
- ASSERT(0);
- return 0;
+ }
+ return;
+ }
}
/* Get the address of INS/OUTS instruction */
-static inline unsigned long svm_get_io_address(struct vmcb_struct *vmcb,
- struct cpu_user_regs *regs, unsigned int dir, unsigned int real)
-{
- unsigned long addr = 0;
- unsigned long base = 0;
-
- check_for_null_selector(vmcb, dir, &base, real);
+static inline int svm_get_io_address(struct vcpu *v,
+ struct cpu_user_regs *regs, unsigned int dir,
+ unsigned long *count, unsigned long *addr)
+{
+ unsigned long reg;
+ unsigned int asize = 0;
+ unsigned int isize;
+ int long_mode;
+ ioio_info_t info;
+ segment_selector_t *seg = NULL;
+ struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
+
+ info.bytes = vmcb->exitinfo1;
+
+ /* If we're in long mode, we shouldn't check the segment presence and
limit */
+ long_mode = vmcb->cs.attributes.fields.l && vmcb->efer & EFER_LMA;
+
+ /* d field of cs.attributes is 1 for 32-bit, 0 for 16 or 64 bit.
+ * l field combined with EFER_LMA -> longmode says whether it's 16 or 64
bit.
+ */
+ asize = (long_mode)?64:((vmcb->cs.attributes.fields.db)?32:16);
+
+
+ /* The ins/outs instructions are single byte, so if we have got more
+ * than one byte (+ maybe rep-prefix), we have some prefix so we need
+ * to figure out what it is...
+ */
+ isize = vmcb->exitinfo2 - vmcb->rip;
+
+ if (info.fields.rep)
+ isize --;
+
+ if (isize > 1)
+ {
+ svm_get_prefix_info(vmcb, dir, &seg, &asize);
+ }
+
+ ASSERT(dir == IOREQ_READ || dir == IOREQ_WRITE);
if (dir == IOREQ_WRITE)
{
- if (real)
- addr = (regs->esi & 0xFFFF) + base;
- else
- addr = regs->esi + base;
+ reg = regs->esi;
+ if (!seg) /* If no prefix, used DS. */
+ seg = &vmcb->ds;
}
else
{
- if (real)
- addr = (regs->edi & 0xFFFF) + base;
- else
- addr = regs->edi + base;
- }
-
- return addr;
+ reg = regs->edi;
+ seg = &vmcb->es; /* Note: This is ALWAYS ES. */
+ }
+
+ /* If the segment isn't present, give GP fault! */
+ if (!long_mode && !seg->attributes.fields.p)
+ {
+ svm_inject_exception(v, TRAP_gp_fault, 1, seg->sel);
+ return 0;
+ }
+
+ if (asize == 16)
+ {
+ *addr = (reg & 0xFFFF);
+ *count = regs->ecx & 0xffff;
+ }
+ else
+ {
+ *addr = reg;
+ *count = regs->ecx;
+ }
+
+ if (!long_mode) {
+ if (*addr > seg->limit)
+ {
+ svm_inject_exception(v, TRAP_gp_fault, 1, seg->sel);
+ return 0;
+ }
+ else
+ {
+ *addr += seg->base;
+ }
+ }
+
+
+ return 1;
}
static void svm_io_instruction(struct vcpu *v, struct cpu_user_regs *regs)
{
struct mmio_op *mmio_opp;
- unsigned long eip, cs, eflags, cr0;
- unsigned long port;
- unsigned int real, size, dir;
+ unsigned int port;
+ unsigned int size, dir;
ioio_info_t info;
-
struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
ASSERT(vmcb);
mmio_opp = ¤t->arch.hvm_vcpu.mmio_op;
mmio_opp->instr = INSTR_PIO;
mmio_opp->flags = 0;
-
- eip = vmcb->rip;
- cs = vmcb->cs.sel;
- eflags = vmcb->rflags;
info.bytes = vmcb->exitinfo1;
@@ -1259,27 +1304,34 @@ static void svm_io_instruction(struct vc
else
size = 1;
- cr0 = vmcb->cr0;
- real = (eflags & X86_EFLAGS_VM) || !(cr0 & X86_CR0_PE);
-
HVM_DBG_LOG(DBG_LEVEL_IO,
- "svm_io_instruction: port 0x%lx real %d, eip=%lx:%lx, "
- "exit_qualification = %lx",
- (unsigned long) port, real, cs, eip, (unsigned
long)info.bytes);
+ "svm_io_instruction: port 0x%x eip=%x:%"PRIx64", "
+ "exit_qualification = %"PRIx64,
+ port, vmcb->cs.sel, vmcb->rip, info.bytes);
+
/* string instruction */
if (info.fields.str)
{
- unsigned long addr, count = 1;
+ unsigned long addr, count;
int sign = regs->eflags & EF_DF ? -1 : 1;
- /* Need the original rip, here. */
- addr = svm_get_io_address(vmcb, regs, dir, real);
+ if (!svm_get_io_address(v, regs, dir, &count, &addr))
+ {
+ /* We failed to get a valid address, so don't do the IO operation -
+ * it would just get worse if we do! Hopefully the guest is handing
+ * gp-faults...
+ */
+ return;
+ }
/* "rep" prefix */
if (info.fields.rep)
{
mmio_opp->flags |= REPZ;
- count = real ? regs->ecx & 0xFFFF : regs->ecx;
+ }
+ else
+ {
+ count = 1;
}
/*
@@ -1368,7 +1420,7 @@ static int svm_set_cr0(unsigned long val
&v->arch.hvm_svm.cpu_state))
{
HVM_DBG_LOG(DBG_LEVEL_1, "Enable paging before PAE enable\n");
- svm_inject_exception(vmcb, TRAP_gp_fault, 1, 0);
+ svm_inject_exception(v, TRAP_gp_fault, 1, 0);
}
if (test_bit(SVM_CPU_STATE_LME_ENABLED, &v->arch.hvm_svm.cpu_state))
@@ -1442,7 +1494,7 @@ static int svm_set_cr0(unsigned long val
*/
if ((value & X86_CR0_PE) == 0) {
if (value & X86_CR0_PG) {
- svm_inject_exception(vmcb, TRAP_gp_fault, 1, 0);
+ svm_inject_exception(v, TRAP_gp_fault, 1, 0);
return 0;
}
@@ -1689,7 +1741,7 @@ static int mov_to_cr(int gpreg, int cr,
} else {
if (test_bit(SVM_CPU_STATE_LMA_ENABLED,
&v->arch.hvm_svm.cpu_state)) {
- svm_inject_exception(vmcb, TRAP_gp_fault, 1, 0);
+ svm_inject_exception(v, TRAP_gp_fault, 1, 0);
}
clear_bit(SVM_CPU_STATE_PAE_ENABLED, &v->arch.hvm_svm.cpu_state);
}
@@ -1805,7 +1857,8 @@ static int svm_cr_access(struct vcpu *v,
break;
case INSTR_SMSW:
- svm_dump_inst(svm_rip2pointer(vmcb));
+ if (svm_dbg_on)
+ svm_dump_inst(svm_rip2pointer(vmcb));
value = v->arch.hvm_svm.cpu_shadow_cr0;
gpreg = decode_src_reg(prefix, buffer[index+2]);
set_reg(gpreg, value, regs, vmcb);
@@ -1942,9 +1995,25 @@ static inline void svm_vmexit_do_hlt(str
}
-static inline void svm_vmexit_do_mwait(void)
-{
-}
+static void svm_vmexit_do_invd(struct vmcb_struct *vmcb)
+{
+ int inst_len;
+
+ /* Invalidate the cache - we can't really do that safely - maybe we should
+ * WBINVD, but I think it's just fine to completely ignore it - we should
+ * have cache-snooping that solves it anyways. -- Mats P.
+ */
+
+ /* Tell the user that we did this - just in case someone runs some really
weird
+ * operating system and wants to know why it's not working as it should...
+ */
+ printk("INVD instruction intercepted - ignored\n");
+
+ inst_len = __get_instruction_length(vmcb, INSTR_INVD, NULL);
+ __update_guest_eip(vmcb, inst_len);
+}
+
+
#ifdef XEN_DEBUGGER
@@ -2006,7 +2075,7 @@ void svm_handle_invlpg(const short invlp
__update_guest_eip(vmcb, inst_len);
/*
- * The address is implicit on this instruction At the moment, we don't
+ * The address is implicit on this instruction. At the moment, we don't
* use ecx (ASID) to identify individual guests pages
*/
g_vaddr = regs->eax;
@@ -2440,7 +2509,6 @@ asmlinkage void svm_vmexit_handler(struc
exit_reason = vmcb->exitcode;
save_svm_cpu_user_regs(v, ®s);
- v->arch.hvm_svm.injecting_event = 0;
vmcb->tlb_control = 1;
@@ -2604,7 +2672,7 @@ asmlinkage void svm_vmexit_handler(struc
if ( test_bit(_DOMF_debugging, &v->domain->domain_flags) )
domain_pause_for_debugger();
else
- svm_inject_exception(vmcb, TRAP_int3, 0, 0);
+ svm_inject_exception(v, TRAP_int3, 0, 0);
#endif
break;
@@ -2615,7 +2683,6 @@ asmlinkage void svm_vmexit_handler(struc
case VMEXIT_EXCEPTION_GP:
/* This should probably not be trapped in the future */
regs.error_code = vmcb->exitinfo1;
- v->arch.hvm_svm.injecting_event = 1;
svm_do_general_protection_fault(v, ®s);
break;
@@ -2635,9 +2702,8 @@ asmlinkage void svm_vmexit_handler(struc
//printk("PF1\n");
if (!(error = svm_do_page_fault(va, ®s)))
{
- v->arch.hvm_svm.injecting_event = 1;
/* Inject #PG using Interruption-Information Fields */
- svm_inject_exception(vmcb, TRAP_page_fault, 1, regs.error_code);
+ svm_inject_exception(v, TRAP_page_fault, 1, regs.error_code);
v->arch.hvm_svm.cpu_cr2 = va;
vmcb->cr2 = va;
@@ -2654,6 +2720,11 @@ asmlinkage void svm_vmexit_handler(struc
case VMEXIT_INTR:
raise_softirq(SCHEDULE_SOFTIRQ);
+ break;
+
+
+ case VMEXIT_INVD:
+ svm_vmexit_do_invd(vmcb);
break;
case VMEXIT_GDTR_WRITE:
@@ -2845,6 +2916,9 @@ asmlinkage void svm_asid(void)
v->arch.hvm_svm.asid_core = v->arch.hvm_svm.launch_core;
clear_bit( ARCH_SVM_VMCB_ASSIGN_ASID, &v->arch.hvm_svm.flags );
}
+
+ /* make sure the HSA is set for the current core */
+ set_hsa_to_guest( &v->arch.hvm_svm );
}
/*
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/arch/x86/hvm/svm/vmcb.c
--- a/xen/arch/x86/hvm/svm/vmcb.c Mon May 22 08:53:26 2006 -0600
+++ b/xen/arch/x86/hvm/svm/vmcb.c Mon May 22 14:13:38 2006 -0600
@@ -36,7 +36,7 @@
#include <xen/kernel.h>
#include <xen/domain_page.h>
-extern struct host_save_area *host_save_area[];
+extern struct svm_percore_globals svm_globals[];
extern int svm_dbg_on;
extern int asidpool_assign_next( struct vmcb_struct *vmcb, int retire_current,
int oldcore, int newcore);
@@ -117,16 +117,12 @@ static int construct_vmcb_controls(struc
/* mask off all general 1 intercepts except those listed here */
vmcb->general1_intercepts =
- ~(GENERAL1_INTERCEPT_CR0_SEL_WRITE | GENERAL1_INTERCEPT_VINTR |
- GENERAL1_INTERCEPT_IDTR_READ | GENERAL1_INTERCEPT_IDTR_WRITE |
- GENERAL1_INTERCEPT_GDTR_READ | GENERAL1_INTERCEPT_GDTR_WRITE |
- GENERAL1_INTERCEPT_LDTR_READ | GENERAL1_INTERCEPT_LDTR_WRITE |
- GENERAL1_INTERCEPT_TR_READ | GENERAL1_INTERCEPT_TR_WRITE |
- GENERAL1_INTERCEPT_RDTSC | GENERAL1_INTERCEPT_PUSHF |
- GENERAL1_INTERCEPT_SWINT | GENERAL1_INTERCEPT_POPF |
- GENERAL1_INTERCEPT_IRET | GENERAL1_INTERCEPT_PAUSE |
- GENERAL1_INTERCEPT_TASK_SWITCH
- );
+ GENERAL1_INTERCEPT_INTR | GENERAL1_INTERCEPT_NMI |
+ GENERAL1_INTERCEPT_SMI | GENERAL1_INTERCEPT_INIT |
+ GENERAL1_INTERCEPT_CPUID | GENERAL1_INTERCEPT_INVD |
+ GENERAL1_INTERCEPT_HLT | GENERAL1_INTERCEPT_INVLPG |
+ GENERAL1_INTERCEPT_INVLPGA | GENERAL1_INTERCEPT_IOIO_PROT |
+ GENERAL1_INTERCEPT_MSR_PROT | GENERAL1_INTERCEPT_SHUTDOWN_EVT;
/* turn on the general 2 intercepts */
vmcb->general2_intercepts =
@@ -143,17 +139,20 @@ static int construct_vmcb_controls(struc
/* The following is for I/O and MSR permision map */
iopm = alloc_xenheap_pages(get_order_from_bytes(IOPM_SIZE));
-
- ASSERT(iopm);
- memset(iopm, 0xff, IOPM_SIZE);
- clear_bit(PC_DEBUG_PORT, iopm);
+ if (iopm)
+ {
+ memset(iopm, 0xff, IOPM_SIZE);
+ clear_bit(PC_DEBUG_PORT, iopm);
+ }
msrpm = alloc_xenheap_pages(get_order_from_bytes(MSRPM_SIZE));
-
- ASSERT(msrpm);
- memset(msrpm, 0xff, MSRPM_SIZE);
+ if (msrpm)
+ memset(msrpm, 0xff, MSRPM_SIZE);
arch_svm->iopm = iopm;
arch_svm->msrpm = msrpm;
+
+ if (! iopm || ! msrpm)
+ return 1;
vmcb->iopm_base_pa = (u64) virt_to_maddr(iopm);
vmcb->msrpm_base_pa = (u64) virt_to_maddr(msrpm);
@@ -421,7 +420,6 @@ void svm_do_launch(struct vcpu *v)
v->arch.schedule_tail = arch_svm_do_resume;
- v->arch.hvm_svm.injecting_event = 0;
v->arch.hvm_svm.saved_irq_vector = -1;
svm_set_guest_time(v, 0);
@@ -435,8 +433,7 @@ void svm_do_launch(struct vcpu *v)
void set_hsa_to_guest( struct arch_svm_struct *arch_svm )
{
- arch_svm->host_save_area = host_save_area[ smp_processor_id() ];
- arch_svm->host_save_pa = (u64)virt_to_maddr( arch_svm->host_save_area );
+ arch_svm->host_save_pa = svm_globals[ smp_processor_id() ].scratch_hsa_pa;
}
/*
@@ -450,9 +447,6 @@ void svm_do_resume(struct vcpu *v)
svm_stts(v);
- /* make sure the HSA is set for the current core */
- set_hsa_to_guest( &v->arch.hvm_svm );
-
/* pick up the elapsed PIT ticks and re-enable pit_timer */
if ( time_info->first_injected ) {
if ( v->domain->arch.hvm_domain.guest_time ) {
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/arch/x86/hvm/vmx/vmcs.c
--- a/xen/arch/x86/hvm/vmx/vmcs.c Mon May 22 08:53:26 2006 -0600
+++ b/xen/arch/x86/hvm/vmx/vmcs.c Mon May 22 14:13:38 2006 -0600
@@ -35,6 +35,7 @@
#include <xen/event.h>
#include <xen/kernel.h>
#include <asm/shadow.h>
+#include <xen/keyhandler.h>
#if CONFIG_PAGING_LEVELS >= 3
#include <asm/shadow_64.h>
#endif
@@ -542,6 +543,101 @@ void arch_vmx_do_launch(struct vcpu *v)
reset_stack_and_jump(vmx_asm_do_launch);
}
+
+/* Dump a section of VMCS */
+static void print_section(char *header, uint32_t start,
+ uint32_t end, int incr)
+{
+ uint32_t addr, j;
+ unsigned long val;
+ int code;
+ char *fmt[4] = {"0x%04lx ", "0x%016lx ", "0x%08lx ", "0x%016lx "};
+ char *err[4] = {"------ ", "------------------ ",
+ "---------- ", "------------------ "};
+
+ /* Find width of the field (encoded in bits 14:13 of address) */
+ code = (start>>13)&3;
+
+ if (header)
+ printk("\t %s", header);
+
+ for (addr=start, j=0; addr<=end; addr+=incr, j++) {
+
+ if (!(j&3))
+ printk("\n\t\t0x%08x: ", addr);
+
+ if (!__vmread(addr, &val))
+ printk(fmt[code], val);
+ else
+ printk("%s", err[code]);
+ }
+
+ printk("\n");
+}
+
+/* Dump current VMCS */
+void vmcs_dump_vcpu(void)
+{
+ print_section("16-bit Guest-State Fields", 0x800, 0x80e, 2);
+ print_section("16-bit Host-State Fields", 0xc00, 0xc0c, 2);
+ print_section("64-bit Control Fields", 0x2000, 0x2013, 1);
+ print_section("64-bit Guest-State Fields", 0x2800, 0x2803, 1);
+ print_section("32-bit Control Fields", 0x4000, 0x401c, 2);
+ print_section("32-bit RO Data Fields", 0x4400, 0x440e, 2);
+ print_section("32-bit Guest-State Fields", 0x4800, 0x482a, 2);
+ print_section("32-bit Host-State Fields", 0x4c00, 0x4c00, 2);
+ print_section("Natural 64-bit Control Fields", 0x6000, 0x600e, 2);
+ print_section("64-bit RO Data Fields", 0x6400, 0x640A, 2);
+ print_section("Natural 64-bit Guest-State Fields", 0x6800, 0x6826, 2);
+ print_section("Natural 64-bit Host-State Fields", 0x6c00, 0x6c16, 2);
+}
+
+
+static void vmcs_dump(unsigned char ch)
+{
+ struct domain *d;
+ struct vcpu *v;
+
+ printk("*********** VMCS Areas **************\n");
+ for_each_domain(d) {
+ printk("\n>>> Domain %d <<<\n", d->domain_id);
+ for_each_vcpu(d, v) {
+
+ /*
+ * Presumably, if a domain is not an HVM guest,
+ * the very first CPU will not pass this test
+ */
+ if (!hvm_guest(v)) {
+ printk("\t\tNot HVM guest\n");
+ break;
+ }
+ printk("\tVCPU %d\n", v->vcpu_id);
+
+ if (v != current) {
+ vcpu_pause(v);
+ __vmptrld(virt_to_maddr(v->arch.hvm_vmx.vmcs));
+ }
+
+ vmcs_dump_vcpu();
+
+ if (v != current) {
+ __vmptrld(virt_to_maddr(current->arch.hvm_vmx.vmcs));
+ vcpu_unpause(v);
+ }
+ }
+ }
+
+ printk("**************************************\n");
+}
+
+static int __init setup_vmcs_dump(void)
+{
+ register_keyhandler('v', vmcs_dump, "dump Intel's VMCS");
+ return 0;
+}
+
+__initcall(setup_vmcs_dump);
+
/*
* Local variables:
* mode: C
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c Mon May 22 08:53:26 2006 -0600
+++ b/xen/arch/x86/hvm/vmx/vmx.c Mon May 22 14:13:38 2006 -0600
@@ -2082,7 +2082,10 @@ asmlinkage void vmx_vmexit_handler(struc
HVM_DBG_LOG(DBG_LEVEL_0, "exit reason = %x", exit_reason);
if (exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY) {
- printk("Failed vm entry\n");
+ printk("Failed vm entry (reason 0x%x)\n", exit_reason);
+ printk("*********** VMCS Area **************\n");
+ vmcs_dump_vcpu();
+ printk("**************************************\n");
domain_crash_synchronous();
return;
}
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Mon May 22 08:53:26 2006 -0600
+++ b/xen/arch/x86/mm.c Mon May 22 14:13:38 2006 -0600
@@ -2811,6 +2811,8 @@ long do_update_descriptor(u64 pa, u64 de
return ret;
}
+typedef struct e820entry e820entry_t;
+DEFINE_XEN_GUEST_HANDLE(e820entry_t);
long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
{
@@ -2867,6 +2869,39 @@ long arch_memory_op(int op, XEN_GUEST_HA
put_domain(d);
break;
+ }
+
+ case XENMEM_memory_map:
+ {
+ return -ENOSYS;
+ }
+
+ case XENMEM_machine_memory_map:
+ {
+ struct xen_memory_map memmap;
+ XEN_GUEST_HANDLE(e820entry_t) buffer;
+ int count;
+
+ if ( !IS_PRIV(current->domain) )
+ return -EINVAL;
+
+ if ( copy_from_guest(&memmap, arg, 1) )
+ return -EFAULT;
+ if ( memmap.nr_entries < e820.nr_map + 1 )
+ return -EINVAL;
+
+ buffer = guest_handle_cast(memmap.buffer, e820entry_t);
+
+ count = min((unsigned int)e820.nr_map, memmap.nr_entries);
+ if ( copy_to_guest(buffer, &e820.map[0], count) < 0 )
+ return -EFAULT;
+
+ memmap.nr_entries = count;
+
+ if ( copy_to_guest(arg, &memmap, 1) )
+ return -EFAULT;
+
+ return 0;
}
default:
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/arch/x86/shadow.c
--- a/xen/arch/x86/shadow.c Mon May 22 08:53:26 2006 -0600
+++ b/xen/arch/x86/shadow.c Mon May 22 14:13:38 2006 -0600
@@ -347,6 +347,13 @@ alloc_shadow_page(struct domain *d,
d->arch.shadow_page_count++;
if ( PGT_l4_page_table == PGT_root_page_table )
pin = 1;
+#if CONFIG_PAGING_LEVELS == 3 & defined (GUEST_PGENTRY_32)
+ /*
+ * We use PGT_l4_shadow for 2-level paging guests on PAE
+ */
+ if ( d->arch.ops->guest_paging_levels == PAGING_L2 )
+ pin = 1;
+#endif
break;
#if CONFIG_PAGING_LEVELS >= 4
@@ -423,7 +430,8 @@ no_shadow_page:
perfc_value(shadow_l2_pages),
perfc_value(hl2_table_pages),
perfc_value(snapshot_pages));
- BUG(); /* XXX FIXME: try a shadow flush to free up some memory. */
+ /* XXX FIXME: try a shadow flush to free up some memory. */
+ domain_crash_synchronous();
return 0;
}
@@ -2425,6 +2433,17 @@ static void shadow_update_pagetables(str
/*
* arch.shadow_table
*/
+#if CONFIG_PAGING_LEVELS == 3 & defined (GUEST_PGENTRY_32)
+ /*
+ * We use PGT_l4_shadow for 2-level paging guests on PAE
+ */
+ if ( d->arch.ops->guest_paging_levels == PAGING_L2 )
+ {
+ if ( unlikely(!(smfn = __shadow_status(d, gpfn, PGT_l4_shadow))) )
+ smfn = shadow_l3_table(v, gpfn, gmfn);
+ }
+ else
+#endif
if ( unlikely(!(smfn = __shadow_status(d, gpfn, PGT_base_page_table))) )
{
#if CONFIG_PAGING_LEVELS == 2
@@ -3046,7 +3065,8 @@ static inline unsigned long init_bl2(
if ( unlikely(!(smfn = alloc_shadow_page(d, gpfn, gmfn, PGT_l4_shadow))) )
{
printk("Couldn't alloc an L4 shadow for pfn=%lx mfn=%lx\n", gpfn,
gmfn);
- BUG(); /* XXX Deal gracefully with failure. */
+ /* XXX Deal gracefully with failure. */
+ domain_crash_synchronous();
}
spl4e = (l4_pgentry_t *)map_domain_page(smfn);
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/arch/x86/shadow32.c
--- a/xen/arch/x86/shadow32.c Mon May 22 08:53:26 2006 -0600
+++ b/xen/arch/x86/shadow32.c Mon May 22 14:13:38 2006 -0600
@@ -246,7 +246,8 @@ alloc_shadow_page(struct domain *d,
perfc_value(shadow_l2_pages),
perfc_value(hl2_table_pages),
perfc_value(snapshot_pages));
- BUG(); /* XXX FIXME: try a shadow flush to free up some memory. */
+ /* XXX FIXME: try a shadow flush to free up some memory. */
+ domain_crash_synchronous();
}
smfn = page_to_mfn(page);
@@ -983,6 +984,11 @@ alloc_p2m_table(struct domain *d)
else
{
page = alloc_domheap_page(NULL);
+ if (!page)
+ {
+ printk("Alloc p2m table fail\n");
+ domain_crash(d);
+ }
l1tab = map_domain_page(page_to_mfn(page));
memset(l1tab, 0, PAGE_SIZE);
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/arch/x86/shadow_public.c
--- a/xen/arch/x86/shadow_public.c Mon May 22 08:53:26 2006 -0600
+++ b/xen/arch/x86/shadow_public.c Mon May 22 14:13:38 2006 -0600
@@ -324,6 +324,11 @@ static void alloc_monitor_pagetable(stru
mmfn_info = alloc_domheap_page(NULL);
ASSERT( mmfn_info );
+ if (!mmfn_info)
+ {
+ printk("Fail to allocate monitor pagetable\n");
+ domain_crash(v->domain);
+ }
mmfn = page_to_mfn(mmfn_info);
mpl4e = (l4_pgentry_t *) map_domain_page_global(mmfn);
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/arch/x86/x86_emulate.c
--- a/xen/arch/x86/x86_emulate.c Mon May 22 08:53:26 2006 -0600
+++ b/xen/arch/x86/x86_emulate.c Mon May 22 14:13:38 2006 -0600
@@ -6,7 +6,7 @@
* Copyright (c) 2005 Keir Fraser
*/
-#ifdef __TEST_HARNESS__
+#ifndef __XEN__
#include <stdio.h>
#include <stdint.h>
#include <public/xen.h>
@@ -1127,7 +1127,7 @@ x86_emulate_memop(
return -1;
}
-#ifndef __TEST_HARNESS__
+#ifdef __XEN__
#include <asm/mm.h>
#include <asm/uaccess.h>
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/common/acm_ops.c
--- a/xen/common/acm_ops.c Mon May 22 08:53:26 2006 -0600
+++ b/xen/common/acm_ops.c Mon May 22 14:13:38 2006 -0600
@@ -32,100 +32,94 @@
#ifndef ACM_SECURITY
-long do_acm_op(XEN_GUEST_HANDLE(acm_op_t) u_acm_op)
+
+long do_acm_op(int cmd, XEN_GUEST_HANDLE(void) arg)
{
return -ENOSYS;
}
+
#else
-enum acm_operation {
- POLICY, /* access to policy interface (early drop) */
- GETPOLICY, /* dump policy cache */
- SETPOLICY, /* set policy cache (controls security) */
- DUMPSTATS, /* dump policy statistics */
- GETSSID, /* retrieve ssidref for domain id (decide
inside authorized domains) */
- GETDECISION /* retrieve ACM decision from authorized
domains */
-};
-
-int acm_authorize_acm_ops(struct domain *d, enum acm_operation pops)
+
+int acm_authorize_acm_ops(struct domain *d)
{
/* currently, policy management functions are restricted to privileged
domains */
if (!IS_PRIV(d))
return -EPERM;
-
return 0;
}
-long do_acm_op(XEN_GUEST_HANDLE(acm_op_t) u_acm_op)
-{
- long ret = 0;
- struct acm_op curop, *op = &curop;
-
- if (acm_authorize_acm_ops(current->domain, POLICY))
+
+long do_acm_op(int cmd, XEN_GUEST_HANDLE(void) arg)
+{
+ long rc = -EFAULT;
+
+ if (acm_authorize_acm_ops(current->domain))
return -EPERM;
- if (copy_from_guest(op, u_acm_op, 1))
- return -EFAULT;
-
- if (op->interface_version != ACM_INTERFACE_VERSION)
- return -EACCES;
-
- switch (op->cmd)
+ switch ( cmd )
{
- case ACM_SETPOLICY:
- {
- ret = acm_authorize_acm_ops(current->domain, SETPOLICY);
- if (!ret)
- ret = acm_set_policy(op->u.setpolicy.pushcache,
- op->u.setpolicy.pushcache_size, 1);
- }
- break;
-
- case ACM_GETPOLICY:
- {
- ret = acm_authorize_acm_ops(current->domain, GETPOLICY);
- if (!ret)
- ret = acm_get_policy(op->u.getpolicy.pullcache,
- op->u.getpolicy.pullcache_size);
- if (!ret)
- copy_to_guest(u_acm_op, op, 1);
- }
- break;
-
- case ACM_DUMPSTATS:
- {
- ret = acm_authorize_acm_ops(current->domain, DUMPSTATS);
- if (!ret)
- ret = acm_dump_statistics(op->u.dumpstats.pullcache,
- op->u.dumpstats.pullcache_size);
- if (!ret)
- copy_to_guest(u_acm_op, op, 1);
- }
- break;
-
- case ACM_GETSSID:
- {
+
+ case ACMOP_setpolicy: {
+ struct acm_setpolicy setpolicy;
+ if (copy_from_guest(&setpolicy, arg, 1) != 0)
+ return -EFAULT;
+ if (setpolicy.interface_version != ACM_INTERFACE_VERSION)
+ return -EACCES;
+
+ rc = acm_set_policy(setpolicy.pushcache,
+ setpolicy.pushcache_size, 1);
+ break;
+ }
+
+ case ACMOP_getpolicy: {
+ struct acm_getpolicy getpolicy;
+ if (copy_from_guest(&getpolicy, arg, 1) != 0)
+ return -EFAULT;
+ if (getpolicy.interface_version != ACM_INTERFACE_VERSION)
+ return -EACCES;
+
+ rc = acm_get_policy(getpolicy.pullcache,
+ getpolicy.pullcache_size);
+ break;
+ }
+
+ case ACMOP_dumpstats: {
+ struct acm_dumpstats dumpstats;
+ if (copy_from_guest(&dumpstats, arg, 1) != 0)
+ return -EFAULT;
+ if (dumpstats.interface_version != ACM_INTERFACE_VERSION)
+ return -EACCES;
+
+ rc = acm_dump_statistics(dumpstats.pullcache,
+ dumpstats.pullcache_size);
+ break;
+ }
+
+ case ACMOP_getssid: {
+ struct acm_getssid getssid;
ssidref_t ssidref;
- ret = acm_authorize_acm_ops(current->domain, GETSSID);
- if (ret)
- break;
-
- if (op->u.getssid.get_ssid_by == SSIDREF)
- ssidref = op->u.getssid.id.ssidref;
- else if (op->u.getssid.get_ssid_by == DOMAINID)
- {
- struct domain *subj = find_domain_by_id(op->u.getssid.id.domainid);
- if (!subj)
- {
- ret = -ESRCH; /* domain not found */
- break;
- }
- if (subj->ssid == NULL)
- {
- put_domain(subj);
- ret = -ESRCH;
+ if (copy_from_guest(&getssid, arg, 1) != 0)
+ return -EFAULT;
+ if (getssid.interface_version != ACM_INTERFACE_VERSION)
+ return -EACCES;
+
+ if (getssid.get_ssid_by == SSIDREF)
+ ssidref = getssid.id.ssidref;
+ else if (getssid.get_ssid_by == DOMAINID)
+ {
+ struct domain *subj = find_domain_by_id(getssid.id.domainid);
+ if (!subj)
+ {
+ rc = -ESRCH; /* domain not found */
+ break;
+ }
+ if (subj->ssid == NULL)
+ {
+ put_domain(subj);
+ rc = -ESRCH;
break;
}
ssidref = ((struct acm_ssid_domain *)(subj->ssid))->ssidref;
@@ -133,39 +127,36 @@ long do_acm_op(XEN_GUEST_HANDLE(acm_op_t
}
else
{
- ret = -ESRCH;
- break;
- }
- ret = acm_get_ssid(ssidref,
- op->u.getssid.ssidbuf,
- op->u.getssid.ssidbuf_size);
- if (!ret)
- copy_to_guest(u_acm_op, op, 1);
- }
- break;
-
- case ACM_GETDECISION:
- {
+ rc = -ESRCH;
+ break;
+ }
+ rc = acm_get_ssid(ssidref, getssid.ssidbuf, getssid.ssidbuf_size);
+ break;
+ }
+
+ case ACMOP_getdecision: {
+ struct acm_getdecision getdecision;
ssidref_t ssidref1, ssidref2;
- ret = acm_authorize_acm_ops(current->domain, GETDECISION);
- if (ret)
- break;
-
- if (op->u.getdecision.get_decision_by1 == SSIDREF)
- ssidref1 = op->u.getdecision.id1.ssidref;
- else if (op->u.getdecision.get_decision_by1 == DOMAINID)
- {
- struct domain *subj =
find_domain_by_id(op->u.getdecision.id1.domainid);
- if (!subj)
- {
- ret = -ESRCH; /* domain not found */
- break;
- }
- if (subj->ssid == NULL)
- {
- put_domain(subj);
- ret = -ESRCH;
+ if (copy_from_guest(&getdecision, arg, 1) != 0)
+ return -EFAULT;
+ if (getdecision.interface_version != ACM_INTERFACE_VERSION)
+ return -EACCES;
+
+ if (getdecision.get_decision_by1 == SSIDREF)
+ ssidref1 = getdecision.id1.ssidref;
+ else if (getdecision.get_decision_by1 == DOMAINID)
+ {
+ struct domain *subj = find_domain_by_id(getdecision.id1.domainid);
+ if (!subj)
+ {
+ rc = -ESRCH; /* domain not found */
+ break;
+ }
+ if (subj->ssid == NULL)
+ {
+ put_domain(subj);
+ rc = -ESRCH;
break;
}
ssidref1 = ((struct acm_ssid_domain *)(subj->ssid))->ssidref;
@@ -173,23 +164,23 @@ long do_acm_op(XEN_GUEST_HANDLE(acm_op_t
}
else
{
- ret = -ESRCH;
- break;
- }
- if (op->u.getdecision.get_decision_by2 == SSIDREF)
- ssidref2 = op->u.getdecision.id2.ssidref;
- else if (op->u.getdecision.get_decision_by2 == DOMAINID)
- {
- struct domain *subj =
find_domain_by_id(op->u.getdecision.id2.domainid);
- if (!subj)
- {
- ret = -ESRCH; /* domain not found */
+ rc = -ESRCH;
+ break;
+ }
+ if (getdecision.get_decision_by2 == SSIDREF)
+ ssidref2 = getdecision.id2.ssidref;
+ else if (getdecision.get_decision_by2 == DOMAINID)
+ {
+ struct domain *subj = find_domain_by_id(getdecision.id2.domainid);
+ if (!subj)
+ {
+ rc = -ESRCH; /* domain not found */
break;;
}
if (subj->ssid == NULL)
{
put_domain(subj);
- ret = -ESRCH;
+ rc = -ESRCH;
break;
}
ssidref2 = ((struct acm_ssid_domain *)(subj->ssid))->ssidref;
@@ -197,34 +188,35 @@ long do_acm_op(XEN_GUEST_HANDLE(acm_op_t
}
else
{
- ret = -ESRCH;
- break;
- }
- ret = acm_get_decision(ssidref1, ssidref2, op->u.getdecision.hook);
-
- if (ret == ACM_ACCESS_PERMITTED)
- {
- op->u.getdecision.acm_decision = ACM_ACCESS_PERMITTED;
- ret = 0;
- }
- else if (ret == ACM_ACCESS_DENIED)
- {
- op->u.getdecision.acm_decision = ACM_ACCESS_DENIED;
- ret = 0;
- }
- else
- ret = -ESRCH;
-
- if (!ret)
- copy_to_guest(u_acm_op, op, 1);
- }
- break;
+ rc = -ESRCH;
+ break;
+ }
+ rc = acm_get_decision(ssidref1, ssidref2, getdecision.hook);
+
+ if (rc == ACM_ACCESS_PERMITTED)
+ {
+ getdecision.acm_decision = ACM_ACCESS_PERMITTED;
+ rc = 0;
+ }
+ else if (rc == ACM_ACCESS_DENIED)
+ {
+ getdecision.acm_decision = ACM_ACCESS_DENIED;
+ rc = 0;
+ }
+ else
+ rc = -ESRCH;
+
+ if ( (rc == 0) && (copy_to_guest(arg, &getdecision, 1) != 0) )
+ rc = -EFAULT;
+ break;
+ }
default:
- ret = -ESRCH;
- }
-
- return ret;
+ rc = -ENOSYS;
+ break;
+ }
+
+ return rc;
}
#endif
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/common/elf.c
--- a/xen/common/elf.c Mon May 22 08:53:26 2006 -0600
+++ b/xen/common/elf.c Mon May 22 14:13:38 2006 -0600
@@ -23,10 +23,10 @@ int parseelfimage(struct domain_setup_in
Elf_Ehdr *ehdr = (Elf_Ehdr *)dsi->image_addr;
Elf_Phdr *phdr;
Elf_Shdr *shdr;
- unsigned long kernstart = ~0UL, kernend=0UL;
+ unsigned long kernstart = ~0UL, kernend=0UL, vaddr, virt_base, elf_pa_off;
char *shstrtab, *guestinfo=NULL, *p;
char *elfbase = (char *)dsi->image_addr;
- int h;
+ int h, virt_base_defined, elf_pa_off_defined;
if ( !elf_sanity_check(ehdr) )
return -EINVAL;
@@ -81,44 +81,68 @@ int parseelfimage(struct domain_setup_in
dsi->xen_section_string = guestinfo;
- for ( h = 0; h < ehdr->e_phnum; h++ )
+ if ( guestinfo == NULL )
+ guestinfo = "";
+
+ /* Initial guess for virt_base is 0 if it is not explicitly defined. */
+ p = strstr(guestinfo, "VIRT_BASE=");
+ virt_base_defined = (p != NULL);
+ virt_base = virt_base_defined ? simple_strtoul(p+10, &p, 0) : 0;
+
+ /* Initial guess for elf_pa_off is virt_base if not explicitly defined. */
+ p = strstr(guestinfo, "ELF_PADDR_OFFSET=");
+ elf_pa_off_defined = (p != NULL);
+ elf_pa_off = elf_pa_off_defined ? simple_strtoul(p+17, &p, 0) : virt_base;
+
+ if ( elf_pa_off_defined && !virt_base_defined )
+ goto bad_image;
+
+ for ( h = 0; h < ehdr->e_phnum; h++ )
{
phdr = (Elf_Phdr *)(elfbase + ehdr->e_phoff + (h*ehdr->e_phentsize));
if ( !is_loadable_phdr(phdr) )
continue;
- if ( phdr->p_paddr < kernstart )
- kernstart = phdr->p_paddr;
- if ( (phdr->p_paddr + phdr->p_memsz) > kernend )
- kernend = phdr->p_paddr + phdr->p_memsz;
- }
+ vaddr = phdr->p_paddr - elf_pa_off + virt_base;
+ if ( (vaddr + phdr->p_memsz) < vaddr )
+ goto bad_image;
+ if ( vaddr < kernstart )
+ kernstart = vaddr;
+ if ( (vaddr + phdr->p_memsz) > kernend )
+ kernend = vaddr + phdr->p_memsz;
+ }
+
+ /*
+ * Legacy compatibility and images with no __xen_guest section: assume
+ * header addresses are virtual addresses, and that guest memory should be
+ * mapped starting at kernel load address.
+ */
+ dsi->v_start = virt_base_defined ? virt_base : kernstart;
+ dsi->elf_paddr_offset = elf_pa_off_defined ? elf_pa_off : dsi->v_start;
+
+ dsi->v_kernentry = ehdr->e_entry;
+ if ( (p = strstr(guestinfo, "VIRT_ENTRY=")) != NULL )
+ dsi->v_kernentry = simple_strtoul(p+11, &p, 0);
if ( (kernstart > kernend) ||
- (ehdr->e_entry < kernstart) ||
- (ehdr->e_entry > kernend) )
- {
- printk("Malformed ELF image.\n");
- return -EINVAL;
- }
-
- dsi->v_start = kernstart;
-
- if ( guestinfo != NULL )
- {
- if ( (p = strstr(guestinfo, "VIRT_BASE=")) != NULL )
- dsi->v_start = simple_strtoul(p+10, &p, 0);
-
- if ( (p = strstr(guestinfo, "BSD_SYMTAB")) != NULL )
+ (dsi->v_kernentry < kernstart) ||
+ (dsi->v_kernentry > kernend) ||
+ (dsi->v_start > kernstart) )
+ goto bad_image;
+
+ if ( (p = strstr(guestinfo, "BSD_SYMTAB")) != NULL )
dsi->load_symtab = 1;
- }
dsi->v_kernstart = kernstart;
dsi->v_kernend = kernend;
- dsi->v_kernentry = ehdr->e_entry;
dsi->v_end = dsi->v_kernend;
loadelfsymtab(dsi, 0);
return 0;
+
+ bad_image:
+ printk("Malformed ELF image.\n");
+ return -EINVAL;
}
int loadelfimage(struct domain_setup_info *dsi)
@@ -126,18 +150,19 @@ int loadelfimage(struct domain_setup_inf
char *elfbase = (char *)dsi->image_addr;
Elf_Ehdr *ehdr = (Elf_Ehdr *)dsi->image_addr;
Elf_Phdr *phdr;
+ unsigned long vaddr;
int h;
- for ( h = 0; h < ehdr->e_phnum; h++ )
+ for ( h = 0; h < ehdr->e_phnum; h++ )
{
phdr = (Elf_Phdr *)(elfbase + ehdr->e_phoff + (h*ehdr->e_phentsize));
if ( !is_loadable_phdr(phdr) )
continue;
+ vaddr = phdr->p_paddr - dsi->elf_paddr_offset + dsi->v_start;
if ( phdr->p_filesz != 0 )
- memcpy((char *)phdr->p_paddr, elfbase + phdr->p_offset,
- phdr->p_filesz);
+ memcpy((char *)vaddr, elfbase + phdr->p_offset, phdr->p_filesz);
if ( phdr->p_memsz > phdr->p_filesz )
- memset((char *)phdr->p_paddr + phdr->p_filesz, 0,
+ memset((char *)vaddr + phdr->p_filesz, 0,
phdr->p_memsz - phdr->p_filesz);
}
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/common/event_channel.c
--- a/xen/common/event_channel.c Mon May 22 08:53:26 2006 -0600
+++ b/xen/common/event_channel.c Mon May 22 14:13:38 2006 -0600
@@ -59,6 +59,9 @@ static int virq_is_global(int virq)
case VIRQ_DEBUG:
case VIRQ_XENOPROF:
rc = 0;
+ break;
+ case VIRQ_ARCH_0 ... VIRQ_ARCH_7:
+ rc = arch_virq_is_global(virq);
break;
default:
rc = 1;
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/asm-ia64/event.h
--- a/xen/include/asm-ia64/event.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/asm-ia64/event.h Mon May 22 14:13:38 2006 -0600
@@ -37,4 +37,21 @@ static inline void evtchn_notify(struct
(!!(v)->vcpu_info->evtchn_upcall_pending & \
!(v)->vcpu_info->evtchn_upcall_mask)
+static inline int arch_virq_is_global(int virq)
+{
+ int rc;
+
+ switch ( virq )
+ {
+ case VIRQ_ITC:
+ rc = 0;
+ break;
+ default:
+ rc = 1;
+ break;
+ }
+
+ return rc;
+}
+
#endif
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/asm-x86/event.h
--- a/xen/include/asm-x86/event.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/asm-x86/event.h Mon May 22 14:13:38 2006 -0600
@@ -31,4 +31,10 @@ static inline void evtchn_notify(struct
(!!(v)->vcpu_info->evtchn_upcall_pending & \
!(v)->vcpu_info->evtchn_upcall_mask)
+/* No arch specific virq definition now. Default to global. */
+static inline int arch_virq_is_global(int virq)
+{
+ return 1;
+}
+
#endif
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/asm-x86/hvm/svm/svm.h
--- a/xen/include/asm-x86/hvm/svm/svm.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/asm-x86/hvm/svm/svm.h Mon May 22 14:13:38 2006 -0600
@@ -70,6 +70,14 @@ struct asid_pool {
u32 asid[ASID_MAX];
};
+struct svm_percore_globals {
+ void *hsa;
+ u64 hsa_pa;
+ void *scratch_hsa;
+ u64 scratch_hsa_pa;
+ struct asid_pool ASIDpool;
+};
+
#define SVM_REG_EAX (0)
#define SVM_REG_ECX (1)
#define SVM_REG_EDX (2)
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/asm-x86/hvm/svm/vmcb.h
--- a/xen/include/asm-x86/hvm/svm/vmcb.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/asm-x86/hvm/svm/vmcb.h Mon May 22 14:13:38 2006 -0600
@@ -440,7 +440,6 @@ struct arch_svm_struct {
u32 *iopm;
u32 *msrpm;
u64 vmexit_tsc; /* tsc read at #VMEXIT. for TSC_OFFSET */
- int injecting_event;
int saved_irq_vector;
u32 launch_core;
u32 asid_core;
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/asm-x86/hvm/vmx/vmcs.h
--- a/xen/include/asm-x86/hvm/vmx/vmcs.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h Mon May 22 14:13:38 2006 -0600
@@ -26,7 +26,7 @@
extern int start_vmx(void);
extern void stop_vmx(void);
-
+extern void vmcs_dump_vcpu(void);
void vmx_final_setup_guest(struct vcpu *v);
void vmx_enter_scheduler(void);
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/asm-x86/hvm/vpic.h
--- a/xen/include/asm-x86/hvm/vpic.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/asm-x86/hvm/vpic.h Mon May 22 14:13:38 2006 -0600
@@ -60,6 +60,7 @@ struct hvm_virpic {
/* IOAPIC callback support */
void (*alt_irq_func)(void *opaque, int irq_num, int level);
void *alt_irq_opaque;
+ spinlock_t lock;
};
@@ -72,7 +73,7 @@ void pic_set_alt_irq_func(struct hvm_vir
void (*alt_irq_func)(void *, int, int),
void *alt_irq_opaque);
int pic_read_irq(struct hvm_virpic *s);
-void pic_update_irq(struct hvm_virpic *s);
+void pic_update_irq(struct hvm_virpic *s); /* Caller must hold s->lock */
uint32_t pic_intack_read(struct hvm_virpic *s);
void register_pic_io_hook (void);
int cpu_get_pic_interrupt(struct vcpu *v, int *type);
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/acm_ops.h
--- a/xen/include/public/acm_ops.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/acm_ops.h Mon May 22 14:13:38 2006 -0600
@@ -2,7 +2,7 @@
* acm_ops.h: Xen access control module hypervisor commands
*
* Reiner Sailer <sailer@xxxxxxxxxxxxxx>
- * Copyright (c) 2005, International Business Machines Corporation.
+ * Copyright (c) 2005,2006 International Business Machines Corporation.
*/
#ifndef __XEN_PUBLIC_ACM_OPS_H__
@@ -17,36 +17,50 @@
* This makes sure that old versions of acm tools will stop working in a
* well-defined way (rather than crashing the machine, for instance).
*/
-#define ACM_INTERFACE_VERSION 0xAAAA0006
+#define ACM_INTERFACE_VERSION 0xAAAA0007
/************************************************************************/
-#define ACM_SETPOLICY 4
+/*
+ * Prototype for this hypercall is:
+ * int acm_op(int cmd, void *args)
+ * @cmd == ACMOP_??? (access control module operation).
+ * @args == Operation-specific extra arguments (NULL if none).
+ */
+
+
+#define ACMOP_setpolicy 1
struct acm_setpolicy {
- /* OUT variables */
+ /* IN */
+ uint32_t interface_version;
void *pushcache;
uint32_t pushcache_size;
};
-#define ACM_GETPOLICY 5
+#define ACMOP_getpolicy 2
struct acm_getpolicy {
- /* OUT variables */
+ /* IN */
+ uint32_t interface_version;
void *pullcache;
uint32_t pullcache_size;
};
-#define ACM_DUMPSTATS 6
+#define ACMOP_dumpstats 3
struct acm_dumpstats {
+ /* IN */
+ uint32_t interface_version;
void *pullcache;
uint32_t pullcache_size;
};
-#define ACM_GETSSID 7
+#define ACMOP_getssid 4
enum get_type {UNSET=0, SSIDREF, DOMAINID};
struct acm_getssid {
+ /* IN */
+ uint32_t interface_version;
enum get_type get_ssid_by;
union {
domaintype_t domainid;
@@ -56,9 +70,11 @@ struct acm_getssid {
uint32_t ssidbuf_size;
};
-#define ACM_GETDECISION 8
+#define ACMOP_getdecision 5
struct acm_getdecision {
- enum get_type get_decision_by1; /* in */
+ /* IN */
+ uint32_t interface_version;
+ enum get_type get_decision_by1;
enum get_type get_decision_by2;
union {
domaintype_t domainid;
@@ -69,23 +85,11 @@ struct acm_getdecision {
ssidref_t ssidref;
} id2;
enum acm_hook_type hook;
- int acm_decision; /* out */
+ /* OUT */
+ int acm_decision;
};
-typedef struct acm_op {
- uint32_t cmd;
- uint32_t interface_version; /* ACM_INTERFACE_VERSION */
- union {
- struct acm_setpolicy setpolicy;
- struct acm_getpolicy getpolicy;
- struct acm_dumpstats dumpstats;
- struct acm_getssid getssid;
- struct acm_getdecision getdecision;
- } u;
-} acm_op_t;
-DEFINE_XEN_GUEST_HANDLE(acm_op_t);
-
-#endif /* __XEN_PUBLIC_ACM_OPS_H__ */
+#endif /* __XEN_PUBLIC_ACM_OPS_H__ */
/*
* Local variables:
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/arch-ia64.h
--- a/xen/include/public/arch-ia64.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/arch-ia64.h Mon May 22 14:13:38 2006 -0600
@@ -38,15 +38,17 @@ DEFINE_XEN_GUEST_HANDLE(void);
#ifndef __ASSEMBLY__
#define MAX_NR_SECTION 32 /* at most 32 memory holes */
-typedef struct {
+struct mm_section {
unsigned long start; /* start of memory hole */
unsigned long end; /* end of memory hole */
-} mm_section_t;
-
-typedef struct {
+};
+typedef struct mm_section mm_section_t;
+
+struct pmt_entry {
unsigned long mfn : 56;
unsigned long type: 8;
-} pmt_entry_t;
+};
+typedef struct pmt_entry pmt_entry_t;
#define GPFN_MEM (0UL << 56) /* Guest pfn is normal mem */
#define GPFN_FRAME_BUFFER (1UL << 56) /* VGA framebuffer */
@@ -93,10 +95,11 @@ typedef struct {
* NB. This may become a 64-bit count with no shift. If this happens then the
* structure size will still be 8 bytes, so no other alignments will change.
*/
-typedef struct {
+struct tsc_timestamp {
unsigned int tsc_bits; /* 0: 32 bits read from the CPU's TSC. */
unsigned int tsc_bitshift; /* 4: 'tsc_bits' uses N:N+31 of TSC. */
-} tsc_timestamp_t; /* 8 bytes */
+}; /* 8 bytes */
+typedef struct tsc_timestamp tsc_timestamp_t;
struct pt_fpreg {
union {
@@ -105,7 +108,7 @@ struct pt_fpreg {
} u;
};
-typedef struct cpu_user_regs{
+struct cpu_user_regs {
/* The following registers are saved by SAVE_MIN: */
unsigned long b6; /* scratch */
unsigned long b7; /* scratch */
@@ -179,9 +182,10 @@ typedef struct cpu_user_regs{
unsigned long eml_unat; /* used for emulating instruction */
unsigned long rfi_pfs; /* used for elulating rfi */
-}cpu_user_regs_t;
-
-typedef union {
+};
+typedef struct cpu_user_regs cpu_user_regs_t;
+
+union vac {
unsigned long value;
struct {
int a_int:1;
@@ -193,9 +197,10 @@ typedef union {
int a_bsw:1;
long reserved:57;
};
-} vac_t;
-
-typedef union {
+};
+typedef union vac vac_t;
+
+union vdc {
unsigned long value;
struct {
int d_vmsw:1;
@@ -206,11 +211,12 @@ typedef union {
int d_itm:1;
long reserved:58;
};
-} vdc_t;
-
-typedef struct {
- vac_t vac;
- vdc_t vdc;
+};
+typedef union vdc vdc_t;
+
+struct mapped_regs {
+ union vac vac;
+ union vdc vdc;
unsigned long virt_env_vaddr;
unsigned long reserved1[29];
unsigned long vhpi;
@@ -290,28 +296,32 @@ typedef struct {
unsigned long reserved6[3456];
unsigned long vmm_avail[128];
unsigned long reserved7[4096];
-} mapped_regs_t;
-
-typedef struct {
-} arch_vcpu_info_t;
+};
+typedef struct mapped_regs mapped_regs_t;
+
+struct arch_vcpu_info {
+};
+typedef struct arch_vcpu_info arch_vcpu_info_t;
typedef mapped_regs_t vpd_t;
-typedef struct {
+struct arch_shared_info {
unsigned int flags;
unsigned long start_info_pfn;
/* Interrupt vector for event channel. */
int evtchn_vector;
-} arch_shared_info_t;
-
-typedef struct {
+};
+typedef struct arch_shared_info arch_shared_info_t;
+
+struct arch_initrd_info {
unsigned long start;
unsigned long size;
-} arch_initrd_info_t;
+};
+typedef struct arch_initrd_info arch_initrd_info_t;
#define IA64_COMMAND_LINE_SIZE 512
-typedef struct vcpu_guest_context {
+struct vcpu_guest_context {
#define VGCF_FPU_VALID (1<<0)
#define VGCF_VMX_GUEST (1<<1)
#define VGCF_IN_KERNEL (1<<2)
@@ -321,12 +331,13 @@ typedef struct vcpu_guest_context {
unsigned long sys_pgnr; /* System pages out of domain memory */
unsigned long vm_assist; /* VMASST_TYPE_* bitmap, now none on IPF */
- cpu_user_regs_t regs;
- mapped_regs_t *privregs;
- arch_shared_info_t shared;
- arch_initrd_info_t initrd;
+ struct cpu_user_regs regs;
+ struct mapped_regs *privregs;
+ struct arch_shared_info shared;
+ struct arch_initrd_info initrd;
char cmdline[IA64_COMMAND_LINE_SIZE];
-} vcpu_guest_context_t;
+};
+typedef struct vcpu_guest_context vcpu_guest_context_t;
DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
// dom0 vp op
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/arch-x86_32.h
--- a/xen/include/public/arch-x86_32.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/arch-x86_32.h Mon May 22 14:13:38 2006 -0600
@@ -95,15 +95,16 @@ DEFINE_XEN_GUEST_HANDLE(void);
#define TI_GET_IF(_ti) ((_ti)->flags & 4)
#define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
#define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2))
-typedef struct trap_info {
+struct trap_info {
uint8_t vector; /* exception vector */
uint8_t flags; /* 0-3: privilege level; 4: clear event enable? */
uint16_t cs; /* code selector */
unsigned long address; /* code offset */
-} trap_info_t;
+};
+typedef struct trap_info trap_info_t;
DEFINE_XEN_GUEST_HANDLE(trap_info_t);
-typedef struct cpu_user_regs {
+struct cpu_user_regs {
uint32_t ebx;
uint32_t ecx;
uint32_t edx;
@@ -124,7 +125,8 @@ typedef struct cpu_user_regs {
uint16_t ds, _pad3;
uint16_t fs, _pad4;
uint16_t gs, _pad5;
-} cpu_user_regs_t;
+};
+typedef struct cpu_user_regs cpu_user_regs_t;
DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
@@ -133,14 +135,14 @@ typedef uint64_t tsc_timestamp_t; /* RDT
* The following is all CPU context. Note that the fpu_ctxt block is filled
* in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
*/
-typedef struct vcpu_guest_context {
+struct vcpu_guest_context {
/* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */
struct { char x[512]; } fpu_ctxt; /* User-level FPU registers */
#define VGCF_I387_VALID (1<<0)
#define VGCF_HVM_GUEST (1<<1)
#define VGCF_IN_KERNEL (1<<2)
unsigned long flags; /* VGCF_* flags */
- cpu_user_regs_t user_regs; /* User-level CPU registers */
+ struct cpu_user_regs user_regs; /* User-level CPU registers */
struct trap_info trap_ctxt[256]; /* Virtual IDT */
unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */
unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
@@ -152,25 +154,29 @@ typedef struct vcpu_guest_context {
unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */
unsigned long failsafe_callback_eip;
unsigned long vm_assist; /* VMASST_TYPE_* bitmap */
-} vcpu_guest_context_t;
+};
+typedef struct vcpu_guest_context vcpu_guest_context_t;
DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
-typedef struct arch_shared_info {
+struct arch_shared_info {
unsigned long max_pfn; /* max pfn that appears in table */
/* Frame containing list of mfns containing list of mfns containing p2m. */
unsigned long pfn_to_mfn_frame_list_list;
unsigned long nmi_reason;
-} arch_shared_info_t;
-
-typedef struct {
+};
+typedef struct arch_shared_info arch_shared_info_t;
+
+struct arch_vcpu_info {
unsigned long cr2;
unsigned long pad[5]; /* sizeof(vcpu_info_t) == 64 */
-} arch_vcpu_info_t;
-
-typedef struct {
+};
+typedef struct arch_vcpu_info arch_vcpu_info_t;
+
+struct xen_callback {
unsigned long cs;
unsigned long eip;
-} xen_callback_t;
+};
+typedef struct xen_callback xen_callback_t;
#endif /* !__ASSEMBLY__ */
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/arch-x86_64.h
--- a/xen/include/public/arch-x86_64.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/arch-x86_64.h Mon May 22 14:13:38 2006 -0600
@@ -150,12 +150,13 @@ struct iret_context {
#define TI_GET_IF(_ti) ((_ti)->flags & 4)
#define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
#define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2))
-typedef struct trap_info {
+struct trap_info {
uint8_t vector; /* exception vector */
uint8_t flags; /* 0-3: privilege level; 4: clear event enable? */
uint16_t cs; /* code selector */
unsigned long address; /* code offset */
-} trap_info_t;
+};
+typedef struct trap_info trap_info_t;
DEFINE_XEN_GUEST_HANDLE(trap_info_t);
#ifdef __GNUC__
@@ -166,7 +167,7 @@ DEFINE_XEN_GUEST_HANDLE(trap_info_t);
#define __DECL_REG(name) uint64_t r ## name
#endif
-typedef struct cpu_user_regs {
+struct cpu_user_regs {
uint64_t r15;
uint64_t r14;
uint64_t r13;
@@ -195,7 +196,8 @@ typedef struct cpu_user_regs {
uint16_t ds, _pad4[3];
uint16_t fs, _pad5[3]; /* Non-zero => takes precedence over fs_base. */
uint16_t gs, _pad6[3]; /* Non-zero => takes precedence over gs_base_usr. */
-} cpu_user_regs_t;
+};
+typedef struct cpu_user_regs cpu_user_regs_t;
DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
#undef __DECL_REG
@@ -206,14 +208,14 @@ typedef uint64_t tsc_timestamp_t; /* RDT
* The following is all CPU context. Note that the fpu_ctxt block is filled
* in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
*/
-typedef struct vcpu_guest_context {
+struct vcpu_guest_context {
/* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */
struct { char x[512]; } fpu_ctxt; /* User-level FPU registers */
#define VGCF_I387_VALID (1<<0)
#define VGCF_HVM_GUEST (1<<1)
#define VGCF_IN_KERNEL (1<<2)
unsigned long flags; /* VGCF_* flags */
- cpu_user_regs_t user_regs; /* User-level CPU registers */
+ struct cpu_user_regs user_regs; /* User-level CPU registers */
struct trap_info trap_ctxt[256]; /* Virtual IDT */
unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */
unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
@@ -228,20 +230,23 @@ typedef struct vcpu_guest_context {
uint64_t fs_base;
uint64_t gs_base_kernel;
uint64_t gs_base_user;
-} vcpu_guest_context_t;
+};
+typedef struct vcpu_guest_context vcpu_guest_context_t;
DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
-typedef struct arch_shared_info {
+struct arch_shared_info {
unsigned long max_pfn; /* max pfn that appears in table */
/* Frame containing list of mfns containing list of mfns containing p2m. */
unsigned long pfn_to_mfn_frame_list_list;
unsigned long nmi_reason;
-} arch_shared_info_t;
-
-typedef struct {
+};
+typedef struct arch_shared_info arch_shared_info_t;
+
+struct arch_vcpu_info {
unsigned long cr2;
unsigned long pad; /* sizeof(vcpu_info_t) == 64 */
-} arch_vcpu_info_t;
+};
+typedef struct arch_vcpu_info arch_vcpu_info_t;
typedef unsigned long xen_callback_t;
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/callback.h
--- a/xen/include/public/callback.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/callback.h Mon May 22 14:13:38 2006 -0600
@@ -32,10 +32,11 @@
* Register a callback.
*/
#define CALLBACKOP_register 0
-typedef struct callback_register {
+struct callback_register {
int type;
xen_callback_t address;
-} callback_register_t;
+};
+typedef struct callback_register callback_register_t;
DEFINE_XEN_GUEST_HANDLE(callback_register_t);
/*
@@ -45,9 +46,10 @@ DEFINE_XEN_GUEST_HANDLE(callback_registe
* you attempt to unregister such a callback.
*/
#define CALLBACKOP_unregister 1
-typedef struct callback_unregister {
+struct callback_unregister {
int type;
-} callback_unregister_t;
+};
+typedef struct callback_unregister callback_unregister_t;
DEFINE_XEN_GUEST_HANDLE(callback_unregister_t);
#endif /* __XEN_PUBLIC_CALLBACK_H__ */
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/dom0_ops.h
--- a/xen/include/public/dom0_ops.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/dom0_ops.h Mon May 22 14:13:38 2006 -0600
@@ -24,14 +24,15 @@
/************************************************************************/
#define DOM0_GETMEMLIST 2
-typedef struct dom0_getmemlist {
+struct dom0_getmemlist {
/* IN variables. */
domid_t domain;
unsigned long max_pfns;
XEN_GUEST_HANDLE(ulong) buffer;
/* OUT variables. */
unsigned long num_pfns;
-} dom0_getmemlist_t;
+};
+typedef struct dom0_getmemlist dom0_getmemlist_t;
DEFINE_XEN_GUEST_HANDLE(dom0_getmemlist_t);
#define DOM0_SCHEDCTL 6
@@ -45,39 +46,43 @@ DEFINE_XEN_GUEST_HANDLE(dom0_adjustdom_t
DEFINE_XEN_GUEST_HANDLE(dom0_adjustdom_t);
#define DOM0_CREATEDOMAIN 8
-typedef struct dom0_createdomain {
+struct dom0_createdomain {
/* IN parameters */
uint32_t ssidref;
xen_domain_handle_t handle;
/* IN/OUT parameters. */
/* Identifier for new domain (auto-allocate if zero is specified). */
domid_t domain;
-} dom0_createdomain_t;
+};
+typedef struct dom0_createdomain dom0_createdomain_t;
DEFINE_XEN_GUEST_HANDLE(dom0_createdomain_t);
#define DOM0_DESTROYDOMAIN 9
-typedef struct dom0_destroydomain {
- /* IN variables. */
- domid_t domain;
-} dom0_destroydomain_t;
+struct dom0_destroydomain {
+ /* IN variables. */
+ domid_t domain;
+};
+typedef struct dom0_destroydomain dom0_destroydomain_t;
DEFINE_XEN_GUEST_HANDLE(dom0_destroydomain_t);
#define DOM0_PAUSEDOMAIN 10
-typedef struct dom0_pausedomain {
+struct dom0_pausedomain {
/* IN parameters. */
domid_t domain;
-} dom0_pausedomain_t;
+};
+typedef struct dom0_pausedomain dom0_pausedomain_t;
DEFINE_XEN_GUEST_HANDLE(dom0_pausedomain_t);
#define DOM0_UNPAUSEDOMAIN 11
-typedef struct dom0_unpausedomain {
+struct dom0_unpausedomain {
/* IN parameters. */
domid_t domain;
-} dom0_unpausedomain_t;
+};
+typedef struct dom0_unpausedomain dom0_unpausedomain_t;
DEFINE_XEN_GUEST_HANDLE(dom0_unpausedomain_t);
#define DOM0_GETDOMAININFO 12
-typedef struct dom0_getdomaininfo {
+struct dom0_getdomaininfo {
/* IN variables. */
domid_t domain; /* NB. IN/OUT variable. */
/* OUT variables. */
@@ -99,21 +104,23 @@ typedef struct dom0_getdomaininfo {
uint32_t max_vcpu_id; /* Maximum VCPUID in use by this domain. */
uint32_t ssidref;
xen_domain_handle_t handle;
-} dom0_getdomaininfo_t;
+};
+typedef struct dom0_getdomaininfo dom0_getdomaininfo_t;
DEFINE_XEN_GUEST_HANDLE(dom0_getdomaininfo_t);
#define DOM0_SETVCPUCONTEXT 13
-typedef struct dom0_setvcpucontext {
+struct dom0_setvcpucontext {
/* IN variables. */
domid_t domain;
uint32_t vcpu;
/* IN/OUT parameters */
XEN_GUEST_HANDLE(vcpu_guest_context_t) ctxt;
-} dom0_setvcpucontext_t;
+};
+typedef struct dom0_setvcpucontext dom0_setvcpucontext_t;
DEFINE_XEN_GUEST_HANDLE(dom0_setvcpucontext_t);
#define DOM0_MSR 15
-typedef struct dom0_msr {
+struct dom0_msr {
/* IN variables. */
uint32_t write;
cpumap_t cpu_mask;
@@ -123,7 +130,8 @@ typedef struct dom0_msr {
/* OUT variables. */
uint32_t out1;
uint32_t out2;
-} dom0_msr_t;
+};
+typedef struct dom0_msr dom0_msr_t;
DEFINE_XEN_GUEST_HANDLE(dom0_msr_t);
/*
@@ -131,12 +139,13 @@ DEFINE_XEN_GUEST_HANDLE(dom0_msr_t);
* 1 January, 1970 if the current system time was <system_time>.
*/
#define DOM0_SETTIME 17
-typedef struct dom0_settime {
+struct dom0_settime {
/* IN variables. */
uint32_t secs;
uint32_t nsecs;
uint64_t system_time;
-} dom0_settime_t;
+};
+typedef struct dom0_settime dom0_settime_t;
DEFINE_XEN_GUEST_HANDLE(dom0_settime_t);
#define DOM0_GETPAGEFRAMEINFO 18
@@ -151,44 +160,47 @@ DEFINE_XEN_GUEST_HANDLE(dom0_settime_t);
#define LTAB_MASK XTAB
#define LTABTYPE_MASK (0x7<<LTAB_SHIFT)
-typedef struct dom0_getpageframeinfo {
+struct dom0_getpageframeinfo {
/* IN variables. */
unsigned long mfn; /* Machine page frame number to query. */
domid_t domain; /* To which domain does the frame belong? */
/* OUT variables. */
/* Is the page PINNED to a type? */
uint32_t type; /* see above type defs */
-} dom0_getpageframeinfo_t;
+};
+typedef struct dom0_getpageframeinfo dom0_getpageframeinfo_t;
DEFINE_XEN_GUEST_HANDLE(dom0_getpageframeinfo_t);
/*
* Read console content from Xen buffer ring.
*/
#define DOM0_READCONSOLE 19
-typedef struct dom0_readconsole {
+struct dom0_readconsole {
/* IN variables. */
uint32_t clear; /* Non-zero -> clear after reading. */
/* IN/OUT variables. */
XEN_GUEST_HANDLE(char) buffer; /* In: Buffer start; Out: Used buffer start
*/
uint32_t count; /* In: Buffer size; Out: Used buffer size */
-} dom0_readconsole_t;
+};
+typedef struct dom0_readconsole dom0_readconsole_t;
DEFINE_XEN_GUEST_HANDLE(dom0_readconsole_t);
/*
* Set which physical cpus a vcpu can execute on.
*/
#define DOM0_SETVCPUAFFINITY 20
-typedef struct dom0_setvcpuaffinity {
+struct dom0_setvcpuaffinity {
/* IN variables. */
domid_t domain;
uint32_t vcpu;
cpumap_t cpumap;
-} dom0_setvcpuaffinity_t;
+};
+typedef struct dom0_setvcpuaffinity dom0_setvcpuaffinity_t;
DEFINE_XEN_GUEST_HANDLE(dom0_setvcpuaffinity_t);
/* Get trace buffers machine base address */
#define DOM0_TBUFCONTROL 21
-typedef struct dom0_tbufcontrol {
+struct dom0_tbufcontrol {
/* IN variables */
#define DOM0_TBUF_GET_INFO 0
#define DOM0_TBUF_SET_CPU_MASK 1
@@ -203,14 +215,15 @@ typedef struct dom0_tbufcontrol {
/* OUT variables */
unsigned long buffer_mfn;
uint32_t size;
-} dom0_tbufcontrol_t;
+};
+typedef struct dom0_tbufcontrol dom0_tbufcontrol_t;
DEFINE_XEN_GUEST_HANDLE(dom0_tbufcontrol_t);
/*
* Get physical information about the host machine
*/
#define DOM0_PHYSINFO 22
-typedef struct dom0_physinfo {
+struct dom0_physinfo {
uint32_t threads_per_core;
uint32_t cores_per_socket;
uint32_t sockets_per_node;
@@ -219,17 +232,19 @@ typedef struct dom0_physinfo {
unsigned long total_pages;
unsigned long free_pages;
uint32_t hw_cap[8];
-} dom0_physinfo_t;
+};
+typedef struct dom0_physinfo dom0_physinfo_t;
DEFINE_XEN_GUEST_HANDLE(dom0_physinfo_t);
/*
* Get the ID of the current scheduler.
*/
#define DOM0_SCHED_ID 24
-typedef struct dom0_sched_id {
+struct dom0_sched_id {
/* OUT variable */
uint32_t sched_id;
-} dom0_sched_id_t;
+};
+typedef struct dom0_physinfo dom0_sched_id_t;
DEFINE_XEN_GUEST_HANDLE(dom0_sched_id_t);
/*
@@ -246,15 +261,16 @@ DEFINE_XEN_GUEST_HANDLE(dom0_sched_id_t)
#define DOM0_SHADOW_CONTROL_OP_CLEAN 11
#define DOM0_SHADOW_CONTROL_OP_PEEK 12
-typedef struct dom0_shadow_control_stats {
+struct dom0_shadow_control_stats {
uint32_t fault_count;
uint32_t dirty_count;
uint32_t dirty_net_count;
uint32_t dirty_block_count;
-} dom0_shadow_control_stats_t;
+};
+typedef struct dom0_shadow_control_stats dom0_shadow_control_stats_t;
DEFINE_XEN_GUEST_HANDLE(dom0_shadow_control_stats_t);
-typedef struct dom0_shadow_control {
+struct dom0_shadow_control {
/* IN variables. */
domid_t domain;
uint32_t op;
@@ -262,26 +278,29 @@ typedef struct dom0_shadow_control {
/* IN/OUT variables. */
unsigned long pages; /* size of buffer, updated with actual size */
/* OUT variables. */
- dom0_shadow_control_stats_t stats;
-} dom0_shadow_control_t;
+ struct dom0_shadow_control_stats stats;
+};
+typedef struct dom0_shadow_control dom0_shadow_control_t;
DEFINE_XEN_GUEST_HANDLE(dom0_shadow_control_t);
#define DOM0_SETDOMAINMAXMEM 28
-typedef struct dom0_setdomainmaxmem {
+struct dom0_setdomainmaxmem {
/* IN variables. */
domid_t domain;
unsigned long max_memkb;
-} dom0_setdomainmaxmem_t;
+};
+typedef struct dom0_setdomainmaxmem dom0_setdomainmaxmem_t;
DEFINE_XEN_GUEST_HANDLE(dom0_setdomainmaxmem_t);
#define DOM0_GETPAGEFRAMEINFO2 29 /* batched interface */
-typedef struct dom0_getpageframeinfo2 {
+struct dom0_getpageframeinfo2 {
/* IN variables. */
domid_t domain;
unsigned long num;
/* IN/OUT variables. */
XEN_GUEST_HANDLE(ulong) array;
-} dom0_getpageframeinfo2_t;
+};
+typedef struct dom0_getpageframeinfo2 dom0_getpageframeinfo2_t;
DEFINE_XEN_GUEST_HANDLE(dom0_getpageframeinfo2_t);
/*
@@ -292,7 +311,7 @@ DEFINE_XEN_GUEST_HANDLE(dom0_getpagefram
* (x86-specific).
*/
#define DOM0_ADD_MEMTYPE 31
-typedef struct dom0_add_memtype {
+struct dom0_add_memtype {
/* IN variables. */
unsigned long mfn;
unsigned long nr_mfns;
@@ -300,7 +319,8 @@ typedef struct dom0_add_memtype {
/* OUT variables. */
uint32_t handle;
uint32_t reg;
-} dom0_add_memtype_t;
+};
+typedef struct dom0_add_memtype dom0_add_memtype_t;
DEFINE_XEN_GUEST_HANDLE(dom0_add_memtype_t);
/*
@@ -311,23 +331,25 @@ DEFINE_XEN_GUEST_HANDLE(dom0_add_memtype
* (x86-specific).
*/
#define DOM0_DEL_MEMTYPE 32
-typedef struct dom0_del_memtype {
+struct dom0_del_memtype {
/* IN variables. */
uint32_t handle;
uint32_t reg;
-} dom0_del_memtype_t;
+};
+typedef struct dom0_del_memtype dom0_del_memtype_t;
DEFINE_XEN_GUEST_HANDLE(dom0_del_memtype_t);
/* Read current type of an MTRR (x86-specific). */
#define DOM0_READ_MEMTYPE 33
-typedef struct dom0_read_memtype {
+struct dom0_read_memtype {
/* IN variables. */
uint32_t reg;
/* OUT variables. */
unsigned long mfn;
unsigned long nr_mfns;
uint32_t type;
-} dom0_read_memtype_t;
+};
+typedef struct dom0_read_memtype dom0_read_memtype_t;
DEFINE_XEN_GUEST_HANDLE(dom0_read_memtype_t);
/* Interface for controlling Xen software performance counters. */
@@ -335,50 +357,56 @@ DEFINE_XEN_GUEST_HANDLE(dom0_read_memtyp
/* Sub-operations: */
#define DOM0_PERFCCONTROL_OP_RESET 1 /* Reset all counters to zero. */
#define DOM0_PERFCCONTROL_OP_QUERY 2 /* Get perfctr information. */
-typedef struct dom0_perfc_desc {
+struct dom0_perfc_desc {
char name[80]; /* name of perf counter */
uint32_t nr_vals; /* number of values for this counter */
uint32_t vals[64]; /* array of values */
-} dom0_perfc_desc_t;
+};
+typedef struct dom0_perfc_desc dom0_perfc_desc_t;
DEFINE_XEN_GUEST_HANDLE(dom0_perfc_desc_t);
-typedef struct dom0_perfccontrol {
+
+struct dom0_perfccontrol {
/* IN variables. */
uint32_t op; /* DOM0_PERFCCONTROL_OP_??? */
/* OUT variables. */
uint32_t nr_counters; /* number of counters */
XEN_GUEST_HANDLE(dom0_perfc_desc_t) desc; /* counter information (or
NULL) */
-} dom0_perfccontrol_t;
+};
+typedef struct dom0_perfccontrol dom0_perfccontrol_t;
DEFINE_XEN_GUEST_HANDLE(dom0_perfccontrol_t);
#define DOM0_MICROCODE 35
-typedef struct dom0_microcode {
+struct dom0_microcode {
/* IN variables. */
XEN_GUEST_HANDLE(void) data; /* Pointer to microcode data */
uint32_t length; /* Length of microcode data. */
-} dom0_microcode_t;
+};
+typedef struct dom0_microcode dom0_microcode_t;
DEFINE_XEN_GUEST_HANDLE(dom0_microcode_t);
#define DOM0_IOPORT_PERMISSION 36
-typedef struct dom0_ioport_permission {
+struct dom0_ioport_permission {
domid_t domain; /* domain to be affected */
uint32_t first_port; /* first port int range */
uint32_t nr_ports; /* size of port range */
uint8_t allow_access; /* allow or deny access to range? */
-} dom0_ioport_permission_t;
+};
+typedef struct dom0_ioport_permission dom0_ioport_permission_t;
DEFINE_XEN_GUEST_HANDLE(dom0_ioport_permission_t);
#define DOM0_GETVCPUCONTEXT 37
-typedef struct dom0_getvcpucontext {
+struct dom0_getvcpucontext {
/* IN variables. */
domid_t domain; /* domain to be affected */
uint32_t vcpu; /* vcpu # */
/* OUT variables. */
XEN_GUEST_HANDLE(vcpu_guest_context_t) ctxt;
-} dom0_getvcpucontext_t;
+};
+typedef struct dom0_getvcpucontext dom0_getvcpucontext_t;
DEFINE_XEN_GUEST_HANDLE(dom0_getvcpucontext_t);
#define DOM0_GETVCPUINFO 43
-typedef struct dom0_getvcpuinfo {
+struct dom0_getvcpuinfo {
/* IN variables. */
domid_t domain; /* domain to be affected */
uint32_t vcpu; /* vcpu # */
@@ -389,92 +417,104 @@ typedef struct dom0_getvcpuinfo {
uint64_t cpu_time; /* total cpu time consumed (ns) */
uint32_t cpu; /* current mapping */
cpumap_t cpumap; /* allowable mapping */
-} dom0_getvcpuinfo_t;
+};
+typedef struct dom0_getvcpuinfo dom0_getvcpuinfo_t;
DEFINE_XEN_GUEST_HANDLE(dom0_getvcpuinfo_t);
#define DOM0_GETDOMAININFOLIST 38
-typedef struct dom0_getdomaininfolist {
+struct dom0_getdomaininfolist {
/* IN variables. */
domid_t first_domain;
uint32_t max_domains;
XEN_GUEST_HANDLE(dom0_getdomaininfo_t) buffer;
/* OUT variables. */
uint32_t num_domains;
-} dom0_getdomaininfolist_t;
+};
+typedef struct dom0_getdomaininfolist dom0_getdomaininfolist_t;
DEFINE_XEN_GUEST_HANDLE(dom0_getdomaininfolist_t);
#define DOM0_PLATFORM_QUIRK 39
#define QUIRK_NOIRQBALANCING 1 /* Do not restrict IO-APIC RTE targets */
#define QUIRK_IOAPIC_BAD_REGSEL 2 /* IO-APIC REGSEL forgets its value */
#define QUIRK_IOAPIC_GOOD_REGSEL 3 /* IO-APIC REGSEL behaves properly */
-typedef struct dom0_platform_quirk {
+struct dom0_platform_quirk {
/* IN variables. */
uint32_t quirk_id;
-} dom0_platform_quirk_t;
+};
+typedef struct dom0_platform_quirk dom0_platform_quirk_t;
DEFINE_XEN_GUEST_HANDLE(dom0_platform_quirk_t);
-#define DOM0_PHYSICAL_MEMORY_MAP 40
-typedef struct dom0_memory_map_entry {
+#define DOM0_PHYSICAL_MEMORY_MAP 40 /* Unimplemented from 3.0.3 onwards */
+struct dom0_memory_map_entry {
uint64_t start, end;
uint32_t flags; /* reserved */
uint8_t is_ram;
-} dom0_memory_map_entry_t;
+};
+typedef struct dom0_memory_map_entry dom0_memory_map_entry_t;
DEFINE_XEN_GUEST_HANDLE(dom0_memory_map_entry_t);
-typedef struct dom0_physical_memory_map {
+
+struct dom0_physical_memory_map {
/* IN variables. */
uint32_t max_map_entries;
/* OUT variables. */
uint32_t nr_map_entries;
XEN_GUEST_HANDLE(dom0_memory_map_entry_t) memory_map;
-} dom0_physical_memory_map_t;
+};
+typedef struct dom0_physical_memory_map dom0_physical_memory_map_t;
DEFINE_XEN_GUEST_HANDLE(dom0_physical_memory_map_t);
#define DOM0_MAX_VCPUS 41
-typedef struct dom0_max_vcpus {
+struct dom0_max_vcpus {
domid_t domain; /* domain to be affected */
uint32_t max; /* maximum number of vcpus */
-} dom0_max_vcpus_t;
+};
+typedef struct dom0_max_vcpus dom0_max_vcpus_t;
DEFINE_XEN_GUEST_HANDLE(dom0_max_vcpus_t);
#define DOM0_SETDOMAINHANDLE 44
-typedef struct dom0_setdomainhandle {
+struct dom0_setdomainhandle {
domid_t domain;
xen_domain_handle_t handle;
-} dom0_setdomainhandle_t;
+};
+typedef struct dom0_setdomainhandle dom0_setdomainhandle_t;
DEFINE_XEN_GUEST_HANDLE(dom0_setdomainhandle_t);
#define DOM0_SETDEBUGGING 45
-typedef struct dom0_setdebugging {
+struct dom0_setdebugging {
domid_t domain;
uint8_t enable;
-} dom0_setdebugging_t;
+};
+typedef struct dom0_setdebugging dom0_setdebugging_t;
DEFINE_XEN_GUEST_HANDLE(dom0_setdebugging_t);
#define DOM0_IRQ_PERMISSION 46
-typedef struct dom0_irq_permission {
+struct dom0_irq_permission {
domid_t domain; /* domain to be affected */
uint8_t pirq;
uint8_t allow_access; /* flag to specify enable/disable of IRQ access */
-} dom0_irq_permission_t;
+};
+typedef struct dom0_irq_permission dom0_irq_permission_t;
DEFINE_XEN_GUEST_HANDLE(dom0_irq_permission_t);
#define DOM0_IOMEM_PERMISSION 47
-typedef struct dom0_iomem_permission {
+struct dom0_iomem_permission {
domid_t domain; /* domain to be affected */
unsigned long first_mfn; /* first page (physical page number) in range */
unsigned long nr_mfns; /* number of pages in range (>0) */
uint8_t allow_access; /* allow (!0) or deny (0) access to range? */
-} dom0_iomem_permission_t;
+};
+typedef struct dom0_iomem_permission dom0_iomem_permission_t;
DEFINE_XEN_GUEST_HANDLE(dom0_iomem_permission_t);
#define DOM0_HYPERCALL_INIT 48
-typedef struct dom0_hypercall_init {
+struct dom0_hypercall_init {
domid_t domain; /* domain to be affected */
unsigned long mfn; /* machine frame to be initialised */
-} dom0_hypercall_init_t;
+};
+typedef struct dom0_hypercall_init dom0_hypercall_init_t;
DEFINE_XEN_GUEST_HANDLE(dom0_hypercall_init_t);
-typedef struct dom0_op {
+struct dom0_op {
uint32_t cmd;
uint32_t interface_version; /* DOM0_INTERFACE_VERSION */
union {
@@ -517,7 +557,8 @@ typedef struct dom0_op {
struct dom0_hypercall_init hypercall_init;
uint8_t pad[128];
} u;
-} dom0_op_t;
+};
+typedef struct dom0_op dom0_op_t;
DEFINE_XEN_GUEST_HANDLE(dom0_op_t);
#endif /* __XEN_PUBLIC_DOM0_OPS_H__ */
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/event_channel.h
--- a/xen/include/public/event_channel.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/event_channel.h Mon May 22 14:13:38 2006 -0600
@@ -28,12 +28,13 @@ DEFINE_XEN_GUEST_HANDLE(evtchn_port_t);
* 2. <rdom> may be DOMID_SELF, allowing loopback connections.
*/
#define EVTCHNOP_alloc_unbound 6
-typedef struct evtchn_alloc_unbound {
+struct evtchn_alloc_unbound {
/* IN parameters */
domid_t dom, remote_dom;
/* OUT parameters */
evtchn_port_t port;
-} evtchn_alloc_unbound_t;
+};
+typedef struct evtchn_alloc_unbound evtchn_alloc_unbound_t;
/*
* EVTCHNOP_bind_interdomain: Construct an interdomain event channel between
@@ -45,13 +46,14 @@ typedef struct evtchn_alloc_unbound {
* 2. <remote_dom> may be DOMID_SELF, allowing loopback connections.
*/
#define EVTCHNOP_bind_interdomain 0
-typedef struct evtchn_bind_interdomain {
+struct evtchn_bind_interdomain {
/* IN parameters. */
domid_t remote_dom;
evtchn_port_t remote_port;
/* OUT parameters. */
evtchn_port_t local_port;
-} evtchn_bind_interdomain_t;
+};
+typedef struct evtchn_bind_interdomain evtchn_bind_interdomain_t;
/*
* EVTCHNOP_bind_virq: Bind a local event channel to VIRQ <irq> on specified
@@ -66,13 +68,14 @@ typedef struct evtchn_bind_interdomain {
* binding cannot be changed.
*/
#define EVTCHNOP_bind_virq 1
-typedef struct evtchn_bind_virq {
+struct evtchn_bind_virq {
/* IN parameters. */
uint32_t virq;
uint32_t vcpu;
/* OUT parameters. */
evtchn_port_t port;
-} evtchn_bind_virq_t;
+};
+typedef struct evtchn_bind_virq evtchn_bind_virq_t;
/*
* EVTCHNOP_bind_pirq: Bind a local event channel to PIRQ <irq>.
@@ -81,14 +84,15 @@ typedef struct evtchn_bind_virq {
* 2. Only a sufficiently-privileged domain may bind to a physical IRQ.
*/
#define EVTCHNOP_bind_pirq 2
-typedef struct evtchn_bind_pirq {
+struct evtchn_bind_pirq {
/* IN parameters. */
uint32_t pirq;
#define BIND_PIRQ__WILL_SHARE 1
uint32_t flags; /* BIND_PIRQ__* */
/* OUT parameters. */
evtchn_port_t port;
-} evtchn_bind_pirq_t;
+};
+typedef struct evtchn_bind_pirq evtchn_bind_pirq_t;
/*
* EVTCHNOP_bind_ipi: Bind a local event channel to receive events.
@@ -97,11 +101,12 @@ typedef struct evtchn_bind_pirq {
* may not be changed.
*/
#define EVTCHNOP_bind_ipi 7
-typedef struct evtchn_bind_ipi {
- uint32_t vcpu;
- /* OUT parameters. */
- evtchn_port_t port;
-} evtchn_bind_ipi_t;
+struct evtchn_bind_ipi {
+ uint32_t vcpu;
+ /* OUT parameters. */
+ evtchn_port_t port;
+};
+typedef struct evtchn_bind_ipi evtchn_bind_ipi_t;
/*
* EVTCHNOP_close: Close a local event channel <port>. If the channel is
@@ -109,20 +114,22 @@ typedef struct evtchn_bind_ipi {
* (EVTCHNSTAT_unbound), awaiting a new connection.
*/
#define EVTCHNOP_close 3
-typedef struct evtchn_close {
- /* IN parameters. */
- evtchn_port_t port;
-} evtchn_close_t;
+struct evtchn_close {
+ /* IN parameters. */
+ evtchn_port_t port;
+};
+typedef struct evtchn_close evtchn_close_t;
/*
* EVTCHNOP_send: Send an event to the remote end of the channel whose local
* endpoint is <port>.
*/
#define EVTCHNOP_send 4
-typedef struct evtchn_send {
- /* IN parameters. */
- evtchn_port_t port;
-} evtchn_send_t;
+struct evtchn_send {
+ /* IN parameters. */
+ evtchn_port_t port;
+};
+typedef struct evtchn_send evtchn_send_t;
/*
* EVTCHNOP_status: Get the current status of the communication channel which
@@ -133,7 +140,7 @@ typedef struct evtchn_send {
* channel for which <dom> is not DOMID_SELF.
*/
#define EVTCHNOP_status 5
-typedef struct evtchn_status {
+struct evtchn_status {
/* IN parameters */
domid_t dom;
evtchn_port_t port;
@@ -157,7 +164,8 @@ typedef struct evtchn_status {
uint32_t pirq; /* EVTCHNSTAT_pirq */
uint32_t virq; /* EVTCHNSTAT_virq */
} u;
-} evtchn_status_t;
+};
+typedef struct evtchn_status evtchn_status_t;
/*
* EVTCHNOP_bind_vcpu: Specify which vcpu a channel should notify when an
@@ -172,41 +180,44 @@ typedef struct evtchn_status {
* has its binding reset to vcpu0).
*/
#define EVTCHNOP_bind_vcpu 8
-typedef struct evtchn_bind_vcpu {
- /* IN parameters. */
- evtchn_port_t port;
- uint32_t vcpu;
-} evtchn_bind_vcpu_t;
+struct evtchn_bind_vcpu {
+ /* IN parameters. */
+ evtchn_port_t port;
+ uint32_t vcpu;
+};
+typedef struct evtchn_bind_vcpu evtchn_bind_vcpu_t;
/*
* EVTCHNOP_unmask: Unmask the specified local event-channel port and deliver
* a notification to the appropriate VCPU if an event is pending.
*/
#define EVTCHNOP_unmask 9
-typedef struct evtchn_unmask {
- /* IN parameters. */
- evtchn_port_t port;
-} evtchn_unmask_t;
+struct evtchn_unmask {
+ /* IN parameters. */
+ evtchn_port_t port;
+};
+typedef struct evtchn_unmask evtchn_unmask_t;
/*
* Argument to event_channel_op_compat() hypercall. Superceded by new
* event_channel_op() hypercall since 0x00030202.
*/
-typedef struct evtchn_op {
+struct evtchn_op {
uint32_t cmd; /* EVTCHNOP_* */
union {
- evtchn_alloc_unbound_t alloc_unbound;
- evtchn_bind_interdomain_t bind_interdomain;
- evtchn_bind_virq_t bind_virq;
- evtchn_bind_pirq_t bind_pirq;
- evtchn_bind_ipi_t bind_ipi;
- evtchn_close_t close;
- evtchn_send_t send;
- evtchn_status_t status;
- evtchn_bind_vcpu_t bind_vcpu;
- evtchn_unmask_t unmask;
+ struct evtchn_alloc_unbound alloc_unbound;
+ struct evtchn_bind_interdomain bind_interdomain;
+ struct evtchn_bind_virq bind_virq;
+ struct evtchn_bind_pirq bind_pirq;
+ struct evtchn_bind_ipi bind_ipi;
+ struct evtchn_close close;
+ struct evtchn_send send;
+ struct evtchn_status status;
+ struct evtchn_bind_vcpu bind_vcpu;
+ struct evtchn_unmask unmask;
} u;
-} evtchn_op_t;
+};
+typedef struct evtchn_op evtchn_op_t;
DEFINE_XEN_GUEST_HANDLE(evtchn_op_t);
#endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/grant_table.h
--- a/xen/include/public/grant_table.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/grant_table.h Mon May 22 14:13:38 2006 -0600
@@ -71,7 +71,7 @@
* [XEN]: This field is written by Xen and read by the sharing guest.
* [GST]: This field is written by the guest and read by Xen.
*/
-typedef struct grant_entry {
+struct grant_entry {
/* GTF_xxx: various type and flag information. [XEN,GST] */
uint16_t flags;
/* The domain being granted foreign privileges. [GST] */
@@ -81,7 +81,8 @@ typedef struct grant_entry {
* GTF_accept_transfer: Frame whose ownership transferred by @domid. [XEN]
*/
uint32_t frame;
-} grant_entry_t;
+};
+typedef struct grant_entry grant_entry_t;
/*
* Type of grant entry.
@@ -156,7 +157,7 @@ typedef uint32_t grant_handle_t;
* to be accounted to the correct grant reference!
*/
#define GNTTABOP_map_grant_ref 0
-typedef struct gnttab_map_grant_ref {
+struct gnttab_map_grant_ref {
/* IN parameters. */
uint64_t host_addr;
uint32_t flags; /* GNTMAP_* */
@@ -166,7 +167,8 @@ typedef struct gnttab_map_grant_ref {
int16_t status; /* GNTST_* */
grant_handle_t handle;
uint64_t dev_bus_addr;
-} gnttab_map_grant_ref_t;
+};
+typedef struct gnttab_map_grant_ref gnttab_map_grant_ref_t;
DEFINE_XEN_GUEST_HANDLE(gnttab_map_grant_ref_t);
/*
@@ -181,14 +183,15 @@ DEFINE_XEN_GUEST_HANDLE(gnttab_map_grant
* mappings will remain in the device or host TLBs.
*/
#define GNTTABOP_unmap_grant_ref 1
-typedef struct gnttab_unmap_grant_ref {
+struct gnttab_unmap_grant_ref {
/* IN parameters. */
uint64_t host_addr;
uint64_t dev_bus_addr;
grant_handle_t handle;
/* OUT parameters. */
int16_t status; /* GNTST_* */
-} gnttab_unmap_grant_ref_t;
+};
+typedef struct gnttab_unmap_grant_ref gnttab_unmap_grant_ref_t;
DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t);
/*
@@ -201,14 +204,15 @@ DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_gra
* 3. Xen may not support more than a single grant-table page per domain.
*/
#define GNTTABOP_setup_table 2
-typedef struct gnttab_setup_table {
+struct gnttab_setup_table {
/* IN parameters. */
domid_t dom;
uint32_t nr_frames;
/* OUT parameters. */
int16_t status; /* GNTST_* */
XEN_GUEST_HANDLE(ulong) frame_list;
-} gnttab_setup_table_t;
+};
+typedef struct gnttab_setup_table gnttab_setup_table_t;
DEFINE_XEN_GUEST_HANDLE(gnttab_setup_table_t);
/*
@@ -216,12 +220,13 @@ DEFINE_XEN_GUEST_HANDLE(gnttab_setup_tab
* xen console. Debugging use only.
*/
#define GNTTABOP_dump_table 3
-typedef struct gnttab_dump_table {
+struct gnttab_dump_table {
/* IN parameters. */
domid_t dom;
/* OUT parameters. */
int16_t status; /* GNTST_* */
-} gnttab_dump_table_t;
+};
+typedef struct gnttab_dump_table gnttab_dump_table_t;
DEFINE_XEN_GUEST_HANDLE(gnttab_dump_table_t);
/*
@@ -233,14 +238,15 @@ DEFINE_XEN_GUEST_HANDLE(gnttab_dump_tabl
* to the calling domain *unless* the error is GNTST_bad_page.
*/
#define GNTTABOP_transfer 4
-typedef struct gnttab_transfer {
+struct gnttab_transfer {
/* IN parameters. */
unsigned long mfn;
domid_t domid;
grant_ref_t ref;
/* OUT parameters. */
int16_t status;
-} gnttab_transfer_t;
+};
+typedef struct gnttab_transfer gnttab_transfer_t;
DEFINE_XEN_GUEST_HANDLE(gnttab_transfer_t);
/*
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/hvm/ioreq.h
--- a/xen/include/public/hvm/ioreq.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/hvm/ioreq.h Mon May 22 14:13:38 2006 -0600
@@ -41,7 +41,7 @@
* prepare this structure and notify service OS and DM by sending
* virq
*/
-typedef struct {
+struct ioreq {
uint64_t addr; /* physical address */
uint64_t size; /* size in bytes */
uint64_t count; /* for rep prefixes */
@@ -55,31 +55,35 @@ typedef struct {
uint8_t df:1;
uint8_t type; /* I/O type */
uint64_t io_count; /* How many IO done on a vcpu */
-} ioreq_t;
+};
+typedef struct ioreq ioreq_t;
#define MAX_VECTOR 256
#define BITS_PER_BYTE 8
#define INTR_LEN (MAX_VECTOR/(BITS_PER_BYTE * sizeof(uint64_t)))
#define INTR_LEN_32 (MAX_VECTOR/(BITS_PER_BYTE * sizeof(uint32_t)))
-typedef struct {
+struct global_iodata {
uint16_t pic_elcr;
uint16_t pic_irr;
uint16_t pic_last_irr;
uint16_t pic_clear_irr;
-} global_iodata_t;
+};
+typedef struct global_iodata global_iodata_t;
-typedef struct {
- ioreq_t vp_ioreq;
+struct vcpu_iodata {
+ struct ioreq vp_ioreq;
/* Event channel port */
unsigned int vp_eport; /* VMX vcpu uses this to notify DM */
unsigned int dm_eport; /* DM uses this to notify VMX vcpu */
-} vcpu_iodata_t;
+};
+typedef struct vcpu_iodata vcpu_iodata_t;
-typedef struct {
- global_iodata_t sp_global;
- vcpu_iodata_t vcpu_iodata[1];
-} shared_iopage_t;
+struct shared_iopage {
+ struct global_iodata sp_global;
+ struct vcpu_iodata vcpu_iodata[1];
+};
+typedef struct shared_iopage shared_iopage_t;
#endif /* _IOREQ_H_ */
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/hvm/vmx_assist.h
--- a/xen/include/public/hvm/vmx_assist.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/hvm/vmx_assist.h Mon May 22 14:13:38 2006 -0600
@@ -37,7 +37,7 @@ union vmcs_arbytes {
/*
* World switch state
*/
-typedef struct vmx_assist_context {
+struct vmx_assist_context {
uint32_t eip; /* execution pointer */
uint32_t esp; /* stack pointer */
uint32_t eflags; /* flags register */
@@ -80,7 +80,8 @@ typedef struct vmx_assist_context {
uint32_t ldtr_limit;
uint32_t ldtr_base;
union vmcs_arbytes ldtr_arbytes;
-} vmx_assist_context_t;
+};
+typedef struct vmx_assist_context vmx_assist_context_t;
#endif /* __ASSEMBLY__ */
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/io/blkif.h
--- a/xen/include/public/io/blkif.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/io/blkif.h Mon May 22 14:13:38 2006 -0600
@@ -39,7 +39,7 @@
*/
#define BLKIF_MAX_SEGMENTS_PER_REQUEST 11
-typedef struct blkif_request {
+struct blkif_request {
uint8_t operation; /* BLKIF_OP_??? */
uint8_t nr_segments; /* number of segments */
blkif_vdev_t handle; /* only for read/write requests */
@@ -51,13 +51,15 @@ typedef struct blkif_request {
/* @last_sect: last sector in frame to transfer (inclusive). */
uint8_t first_sect, last_sect;
} seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
-} blkif_request_t;
+};
+typedef struct blkif_request blkif_request_t;
-typedef struct blkif_response {
+struct blkif_response {
uint64_t id; /* copied from request */
uint8_t operation; /* copied from request */
int16_t status; /* BLKIF_RSP_??? */
-} blkif_response_t;
+};
+typedef struct blkif_response blkif_response_t;
#define BLKIF_RSP_ERROR -1 /* non-specific 'error' */
#define BLKIF_RSP_OKAY 0 /* non-specific 'okay' */
@@ -66,7 +68,7 @@ typedef struct blkif_response {
* Generate blkif ring structures and types.
*/
-DEFINE_RING_TYPES(blkif, blkif_request_t, blkif_response_t);
+DEFINE_RING_TYPES(blkif, struct blkif_request, struct blkif_response);
#define VDISK_CDROM 0x1
#define VDISK_REMOVABLE 0x2
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/io/netif.h
--- a/xen/include/public/io/netif.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/io/netif.h Mon May 22 14:13:38 2006 -0600
@@ -13,10 +13,10 @@
#include "../grant_table.h"
/*
- * Note that there is *never* any need to notify the backend when enqueuing
- * receive requests (netif_rx_request_t). Notifications after enqueuing any
- * other type of message should be conditional on the appropriate req_event
- * or rsp_event field in the shared ring.
+ * Note that there is *never* any need to notify the backend when
+ * enqueuing receive requests (struct netif_rx_request). Notifications
+ * after enqueuing any other type of message should be conditional on
+ * the appropriate req_event or rsp_event field in the shared ring.
*/
/* Protocol checksum field is blank in the packet (hardware offload)? */
@@ -27,23 +27,26 @@
#define _NETTXF_data_validated (1)
#define NETTXF_data_validated (1U<<_NETTXF_data_validated)
-typedef struct netif_tx_request {
+struct netif_tx_request {
grant_ref_t gref; /* Reference to buffer page */
uint16_t offset; /* Offset within buffer page */
uint16_t flags; /* NETTXF_* */
uint16_t id; /* Echoed in response message. */
uint16_t size; /* Packet size in bytes. */
-} netif_tx_request_t;
+};
+typedef struct netif_tx_request netif_tx_request_t;
-typedef struct netif_tx_response {
+struct netif_tx_response {
uint16_t id;
int16_t status; /* NETIF_RSP_* */
-} netif_tx_response_t;
+};
+typedef struct netif_tx_response netif_tx_response_t;
-typedef struct {
+struct netif_rx_request {
uint16_t id; /* Echoed in response message. */
grant_ref_t gref; /* Reference to incoming granted frame */
-} netif_rx_request_t;
+};
+typedef struct netif_rx_request netif_rx_request_t;
/* Packet data has been validated against protocol checksum. */
#define _NETRXF_data_validated (0)
@@ -53,19 +56,20 @@ typedef struct {
#define _NETRXF_csum_blank (1)
#define NETRXF_csum_blank (1U<<_NETRXF_csum_blank)
-typedef struct {
+struct netif_rx_response {
uint16_t id;
uint16_t offset; /* Offset in page of start of received packet */
uint16_t flags; /* NETRXF_* */
int16_t status; /* -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */
-} netif_rx_response_t;
+};
+typedef struct netif_rx_response netif_rx_response_t;
/*
* Generate netif ring structures and types.
*/
-DEFINE_RING_TYPES(netif_tx, netif_tx_request_t, netif_tx_response_t);
-DEFINE_RING_TYPES(netif_rx, netif_rx_request_t, netif_rx_response_t);
+DEFINE_RING_TYPES(netif_tx, struct netif_tx_request, struct netif_tx_response);
+DEFINE_RING_TYPES(netif_rx, struct netif_rx_request, struct netif_rx_response);
#define NETIF_RSP_DROPPED -2
#define NETIF_RSP_ERROR -1
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/io/tpmif.h
--- a/xen/include/public/io/tpmif.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/io/tpmif.h Mon May 22 14:13:38 2006 -0600
@@ -18,12 +18,13 @@
#include "../grant_table.h"
-typedef struct {
+struct tpmif_tx_request {
unsigned long addr; /* Machine address of packet. */
grant_ref_t ref; /* grant table access reference */
uint16_t unused;
uint16_t size; /* Packet size in bytes. */
-} tpmif_tx_request_t;
+};
+typedef struct tpmif_tx_request tpmif_tx_request_t;
/*
* The TPMIF_TX_RING_SIZE defines the number of pages the
@@ -35,13 +36,15 @@ typedef uint32_t TPMIF_RING_IDX;
/* This structure must fit in a memory page. */
-typedef struct {
- tpmif_tx_request_t req;
-} tpmif_ring_t;
+struct tpmif_ring {
+ struct tpmif_tx_request req;
+};
+typedef struct tpmif_ring tpmif_ring_t;
-typedef struct {
- tpmif_ring_t ring[TPMIF_TX_RING_SIZE];
-} tpmif_tx_interface_t;
+struct tpmif_tx_interface {
+ struct tpmif_ring ring[TPMIF_TX_RING_SIZE];
+};
+typedef struct tpmif_tx_interface tpmif_tx_interface_t;
#endif
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/memory.h
--- a/xen/include/public/memory.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/memory.h Mon May 22 14:13:38 2006 -0600
@@ -17,7 +17,7 @@
#define XENMEM_increase_reservation 0
#define XENMEM_decrease_reservation 1
#define XENMEM_populate_physmap 6
-typedef struct xen_memory_reservation {
+struct xen_memory_reservation {
/*
* XENMEM_increase_reservation:
@@ -49,7 +49,8 @@ typedef struct xen_memory_reservation {
*/
domid_t domid;
-} xen_memory_reservation_t;
+};
+typedef struct xen_memory_reservation xen_memory_reservation_t;
DEFINE_XEN_GUEST_HANDLE(xen_memory_reservation_t);
/*
@@ -74,7 +75,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_memory_reser
* arg == addr of xen_machphys_mfn_list_t.
*/
#define XENMEM_machphys_mfn_list 5
-typedef struct xen_machphys_mfn_list {
+struct xen_machphys_mfn_list {
/*
* Size of the 'extent_start' array. Fewer entries will be filled if the
* machphys table is smaller than max_extents * 2MB.
@@ -93,7 +94,8 @@ typedef struct xen_machphys_mfn_list {
* than 'max_extents' if the machphys table is smaller than max_e * 2MB.
*/
unsigned int nr_extents;
-} xen_machphys_mfn_list_t;
+};
+typedef struct xen_machphys_mfn_list xen_machphys_mfn_list_t;
DEFINE_XEN_GUEST_HANDLE(xen_machphys_mfn_list_t);
/*
@@ -102,7 +104,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_machphys_mfn
* arg == addr of xen_add_to_physmap_t.
*/
#define XENMEM_add_to_physmap 7
-typedef struct xen_add_to_physmap {
+struct xen_add_to_physmap {
/* Which domain to change the mapping for. */
domid_t domid;
@@ -116,7 +118,8 @@ typedef struct xen_add_to_physmap {
/* GPFN where the source mapping page should appear. */
unsigned long gpfn;
-} xen_add_to_physmap_t;
+};
+typedef struct xen_add_to_physmap xen_add_to_physmap_t;
DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t);
/*
@@ -124,7 +127,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_add_to_physm
* code on failure. This call only works for auto-translated guests.
*/
#define XENMEM_translate_gpfn_list 8
-typedef struct xen_translate_gpfn_list {
+struct xen_translate_gpfn_list {
/* Which domain to translate for? */
domid_t domid;
@@ -139,8 +142,37 @@ typedef struct xen_translate_gpfn_list {
* list (in which case each input GPFN is overwritten with the output MFN).
*/
XEN_GUEST_HANDLE(ulong) mfn_list;
-} xen_translate_gpfn_list_t;
+};
+typedef struct xen_translate_gpfn_list xen_translate_gpfn_list_t;
DEFINE_XEN_GUEST_HANDLE(xen_translate_gpfn_list_t);
+
+/*
+ * Returns the pseudo-physical memory map as it was when the domain
+ * was started.
+ */
+#define XENMEM_memory_map 9
+struct xen_memory_map {
+ /*
+ * On call the number of entries which can be stored in buffer. On
+ * return the number of entries which have been stored in
+ * buffer.
+ */
+ unsigned int nr_entries;
+
+ /*
+ * Entries in the buffer are in the same format as returned by the
+ * BIOS INT 0x15 EAX=0xE820 call.
+ */
+ XEN_GUEST_HANDLE(void) buffer;
+};
+typedef struct xen_memory_map xen_memory_map_t;
+DEFINE_XEN_GUEST_HANDLE(xen_memory_map_t);
+
+/*
+ * Returns the real physical memory map. Passes the same structure as
+ * XENMEM_memory_map.
+ */
+#define XENMEM_machine_memory_map 10
#endif /* __XEN_PUBLIC_MEMORY_H__ */
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/nmi.h
--- a/xen/include/public/nmi.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/nmi.h Mon May 22 14:13:38 2006 -0600
@@ -34,10 +34,11 @@
* arg == pointer to xennmi_callback structure.
*/
#define XENNMI_register_callback 0
-typedef struct xennmi_callback {
+struct xennmi_callback {
unsigned long handler_address;
unsigned long pad;
-} xennmi_callback_t;
+};
+typedef struct xennmi_callback xennmi_callback_t;
DEFINE_XEN_GUEST_HANDLE(xennmi_callback_t);
/*
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/physdev.h
--- a/xen/include/public/physdev.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/physdev.h Mon May 22 14:13:38 2006 -0600
@@ -14,10 +14,11 @@
* @arg == pointer to physdev_eoi structure.
*/
#define PHYSDEVOP_eoi 12
-typedef struct physdev_eoi {
+struct physdev_eoi {
/* IN */
uint32_t irq;
-} physdev_eoi_t;
+};
+typedef struct physdev_eoi physdev_eoi_t;
DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t);
/*
@@ -25,12 +26,13 @@ DEFINE_XEN_GUEST_HANDLE(physdev_eoi_t);
* @arg == pointer to physdev_irq_status_query structure.
*/
#define PHYSDEVOP_irq_status_query 5
-typedef struct physdev_irq_status_query {
+struct physdev_irq_status_query {
/* IN */
uint32_t irq;
/* OUT */
uint32_t flags; /* XENIRQSTAT_* */
-} physdev_irq_status_query_t;
+};
+typedef struct physdev_irq_status_query physdev_irq_status_query_t;
DEFINE_XEN_GUEST_HANDLE(physdev_irq_status_query_t);
/* Need to call PHYSDEVOP_eoi when the IRQ has been serviced? */
@@ -42,10 +44,11 @@ DEFINE_XEN_GUEST_HANDLE(physdev_irq_stat
* @arg == pointer to physdev_set_iopl structure.
*/
#define PHYSDEVOP_set_iopl 6
-typedef struct physdev_set_iopl {
+struct physdev_set_iopl {
/* IN */
uint32_t iopl;
-} physdev_set_iopl_t;
+};
+typedef struct physdev_set_iopl physdev_set_iopl_t;
DEFINE_XEN_GUEST_HANDLE(physdev_set_iopl_t);
/*
@@ -53,11 +56,12 @@ DEFINE_XEN_GUEST_HANDLE(physdev_set_iopl
* @arg == pointer to physdev_set_iobitmap structure.
*/
#define PHYSDEVOP_set_iobitmap 7
-typedef struct physdev_set_iobitmap {
+struct physdev_set_iobitmap {
/* IN */
uint8_t *bitmap;
uint32_t nr_ports;
-} physdev_set_iobitmap_t;
+};
+typedef struct physdev_set_iobitmap physdev_set_iobitmap_t;
DEFINE_XEN_GUEST_HANDLE(physdev_set_iobitmap_t);
/*
@@ -66,13 +70,14 @@ DEFINE_XEN_GUEST_HANDLE(physdev_set_iobi
*/
#define PHYSDEVOP_apic_read 8
#define PHYSDEVOP_apic_write 9
-typedef struct physdev_apic {
+struct physdev_apic {
/* IN */
unsigned long apic_physbase;
uint32_t reg;
/* IN or OUT */
uint32_t value;
-} physdev_apic_t;
+};
+typedef struct physdev_apic physdev_apic_t;
DEFINE_XEN_GUEST_HANDLE(physdev_apic_t);
/*
@@ -81,28 +86,30 @@ DEFINE_XEN_GUEST_HANDLE(physdev_apic_t);
*/
#define PHYSDEVOP_alloc_irq_vector 10
#define PHYSDEVOP_free_irq_vector 11
-typedef struct physdev_irq {
+struct physdev_irq {
/* IN */
uint32_t irq;
/* IN or OUT */
uint32_t vector;
-} physdev_irq_t;
+};
+typedef struct physdev_irq physdev_irq_t;
DEFINE_XEN_GUEST_HANDLE(physdev_irq_t);
/*
* Argument to physdev_op_compat() hypercall. Superceded by new physdev_op()
* hypercall since 0x00030202.
*/
-typedef struct physdev_op {
+struct physdev_op {
uint32_t cmd;
union {
- physdev_irq_status_query_t irq_status_query;
- physdev_set_iopl_t set_iopl;
- physdev_set_iobitmap_t set_iobitmap;
- physdev_apic_t apic_op;
- physdev_irq_t irq_op;
+ struct physdev_irq_status_query irq_status_query;
+ struct physdev_set_iopl set_iopl;
+ struct physdev_set_iobitmap set_iobitmap;
+ struct physdev_apic apic_op;
+ struct physdev_irq irq_op;
} u;
-} physdev_op_t;
+};
+typedef struct physdev_op physdev_op_t;
DEFINE_XEN_GUEST_HANDLE(physdev_op_t);
/*
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/sched.h
--- a/xen/include/public/sched.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/sched.h Mon May 22 14:13:38 2006 -0600
@@ -46,9 +46,10 @@
* @arg == pointer to sched_shutdown structure.
*/
#define SCHEDOP_shutdown 2
-typedef struct sched_shutdown {
+struct sched_shutdown {
unsigned int reason; /* SHUTDOWN_* */
-} sched_shutdown_t;
+};
+typedef struct sched_shutdown sched_shutdown_t;
DEFINE_XEN_GUEST_HANDLE(sched_shutdown_t);
/*
@@ -57,11 +58,12 @@ DEFINE_XEN_GUEST_HANDLE(sched_shutdown_t
* @arg == pointer to sched_poll structure.
*/
#define SCHEDOP_poll 3
-typedef struct sched_poll {
+struct sched_poll {
XEN_GUEST_HANDLE(evtchn_port_t) ports;
unsigned int nr_ports;
uint64_t timeout;
-} sched_poll_t;
+};
+typedef struct sched_poll sched_poll_t;
DEFINE_XEN_GUEST_HANDLE(sched_poll_t);
/*
@@ -71,10 +73,11 @@ DEFINE_XEN_GUEST_HANDLE(sched_poll_t);
* @arg == pointer to sched_remote_shutdown structure.
*/
#define SCHEDOP_remote_shutdown 4
-typedef struct sched_remote_shutdown {
+struct sched_remote_shutdown {
domid_t domain_id; /* Remote domain ID */
unsigned int reason; /* SHUTDOWN_xxx reason */
-} sched_remote_shutdown_t;
+};
+typedef struct sched_remote_shutdown sched_remote_shutdown_t;
DEFINE_XEN_GUEST_HANDLE(sched_remote_shutdown_t);
/*
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/vcpu.h
--- a/xen/include/public/vcpu.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/vcpu.h Mon May 22 14:13:38 2006 -0600
@@ -56,7 +56,7 @@
* @extra_arg == pointer to vcpu_runstate_info structure.
*/
#define VCPUOP_get_runstate_info 4
-typedef struct vcpu_runstate_info {
+struct vcpu_runstate_info {
/* VCPU's current state (RUNSTATE_*). */
int state;
/* When was current state entered (system time, ns)? */
@@ -66,7 +66,8 @@ typedef struct vcpu_runstate_info {
* guaranteed not to drift from system time.
*/
uint64_t time[4];
-} vcpu_runstate_info_t;
+};
+typedef struct vcpu_runstate_info vcpu_runstate_info_t;
/* VCPU is currently running on a physical CPU. */
#define RUNSTATE_running 0
@@ -99,12 +100,13 @@ typedef struct vcpu_runstate_info {
* @extra_arg == pointer to vcpu_register_runstate_memory_area structure.
*/
#define VCPUOP_register_runstate_memory_area 5
-typedef struct vcpu_register_runstate_memory_area {
+struct vcpu_register_runstate_memory_area {
union {
struct vcpu_runstate_info *v;
uint64_t p;
} addr;
-} vcpu_register_runstate_memory_area_t;
+};
+typedef struct vcpu_register_runstate_memory_area
vcpu_register_runstate_memory_area_t;
#endif /* __XEN_PUBLIC_VCPU_H__ */
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/version.h
--- a/xen/include/public/version.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/version.h Mon May 22 14:13:38 2006 -0600
@@ -22,12 +22,13 @@ typedef char xen_extraversion_t[16];
/* arg == xen_compile_info_t. */
#define XENVER_compile_info 2
-typedef struct xen_compile_info {
+struct xen_compile_info {
char compiler[64];
char compile_by[16];
char compile_domain[32];
char compile_date[32];
-} xen_compile_info_t;
+};
+typedef struct xen_compile_info xen_compile_info_t;
#define XENVER_capabilities 3
typedef char xen_capabilities_info_t[1024];
@@ -38,15 +39,17 @@ typedef char xen_changeset_info_t[64];
#define XEN_CHANGESET_INFO_LEN (sizeof(xen_changeset_info_t))
#define XENVER_platform_parameters 5
-typedef struct xen_platform_parameters {
+struct xen_platform_parameters {
unsigned long virt_start;
-} xen_platform_parameters_t;
+};
+typedef struct xen_platform_parameters xen_platform_parameters_t;
#define XENVER_get_features 6
-typedef struct xen_feature_info {
+struct xen_feature_info {
unsigned int submap_idx; /* IN: which 32-bit submap to return */
uint32_t submap; /* OUT: 32-bit submap */
-} xen_feature_info_t;
+};
+typedef struct xen_feature_info xen_feature_info_t;
/* Declares the features reported by XENVER_get_features. */
#include "features.h"
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/xen.h
--- a/xen/include/public/xen.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/xen.h Mon May 22 14:13:38 2006 -0600
@@ -193,7 +193,7 @@
#define MMUEXT_NEW_USER_BASEPTR 15
#ifndef __ASSEMBLY__
-typedef struct mmuext_op {
+struct mmuext_op {
unsigned int cmd;
union {
/* [UN]PIN_TABLE, NEW_BASEPTR, NEW_USER_BASEPTR */
@@ -207,7 +207,8 @@ typedef struct mmuext_op {
/* TLB_FLUSH_MULTI, INVLPG_MULTI */
void *vcpumask;
} arg2;
-} mmuext_op_t;
+};
+typedef struct mmuext_op mmuext_op_t;
DEFINE_XEN_GUEST_HANDLE(mmuext_op_t);
#endif
@@ -271,20 +272,22 @@ typedef uint16_t domid_t;
* Send an array of these to HYPERVISOR_mmu_update().
* NB. The fields are natural pointer/address size for this architecture.
*/
-typedef struct mmu_update {
+struct mmu_update {
uint64_t ptr; /* Machine address of PTE. */
uint64_t val; /* New contents of PTE. */
-} mmu_update_t;
+};
+typedef struct mmu_update mmu_update_t;
DEFINE_XEN_GUEST_HANDLE(mmu_update_t);
/*
* Send an array of these to HYPERVISOR_multicall().
* NB. The fields are natural register size for this architecture.
*/
-typedef struct multicall_entry {
+struct multicall_entry {
unsigned long op, result;
unsigned long args[6];
-} multicall_entry_t;
+};
+typedef struct multicall_entry multicall_entry_t;
DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);
/*
@@ -293,7 +296,7 @@ DEFINE_XEN_GUEST_HANDLE(multicall_entry_
*/
#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64)
-typedef struct vcpu_time_info {
+struct vcpu_time_info {
/*
* Updates to the following values are preceded and followed by an
* increment of 'version'. The guest can therefore detect updates by
@@ -317,9 +320,10 @@ typedef struct vcpu_time_info {
uint32_t tsc_to_system_mul;
int8_t tsc_shift;
int8_t pad1[3];
-} vcpu_time_info_t; /* 32 bytes */
-
-typedef struct vcpu_info {
+}; /* 32 bytes */
+typedef struct vcpu_time_info vcpu_time_info_t;
+
+struct vcpu_info {
/*
* 'evtchn_upcall_pending' is written non-zero by Xen to indicate
* a pending notification for a particular VCPU. It is then cleared
@@ -348,16 +352,17 @@ typedef struct vcpu_info {
uint8_t evtchn_upcall_pending;
uint8_t evtchn_upcall_mask;
unsigned long evtchn_pending_sel;
- arch_vcpu_info_t arch;
- vcpu_time_info_t time;
-} vcpu_info_t; /* 64 bytes (x86) */
+ struct arch_vcpu_info arch;
+ struct vcpu_time_info time;
+}; /* 64 bytes (x86) */
+typedef struct vcpu_info vcpu_info_t;
/*
* Xen/kernel shared data -- pointer provided in start_info.
* NB. We expect that this struct is smaller than a page.
*/
-typedef struct shared_info {
- vcpu_info_t vcpu_info[MAX_VIRT_CPUS];
+struct shared_info {
+ struct vcpu_info vcpu_info[MAX_VIRT_CPUS];
/*
* A domain can create "event channels" on which it can send and receive
@@ -401,9 +406,10 @@ typedef struct shared_info {
uint32_t wc_sec; /* Secs 00:00:00 UTC, Jan 1, 1970. */
uint32_t wc_nsec; /* Nsecs 00:00:00 UTC, Jan 1, 1970. */
- arch_shared_info_t arch;
-
-} shared_info_t;
+ struct arch_shared_info arch;
+
+};
+typedef struct shared_info shared_info_t;
/*
* Start-of-day memory layout for the initial domain (DOM0):
@@ -431,7 +437,7 @@ typedef struct shared_info {
*/
#define MAX_GUEST_CMDLINE 1024
-typedef struct start_info {
+struct start_info {
/* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME. */
char magic[32]; /* "xen-<version>-<platform>". */
unsigned long nr_pages; /* Total pages allocated to this domain. */
@@ -448,7 +454,8 @@ typedef struct start_info {
unsigned long mod_start; /* VIRTUAL address of pre-loaded module. */
unsigned long mod_len; /* Size (bytes) of pre-loaded module. */
int8_t cmd_line[MAX_GUEST_CMDLINE];
-} start_info_t;
+};
+typedef struct start_info start_info_t;
/* These flags are passed in the 'flags' field of start_info_t. */
#define SIF_PRIVILEGED (1<<0) /* Is the domain privileged? */
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/public/xenoprof.h
--- a/xen/include/public/xenoprof.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/public/xenoprof.h Mon May 22 14:13:38 2006 -0600
@@ -41,7 +41,7 @@ struct event_log {
};
/* Xenoprof buffer shared between Xen and domain - 1 per VCPU */
-typedef struct xenoprof_buf {
+struct xenoprof_buf {
uint32_t event_head;
uint32_t event_tail;
uint32_t event_size;
@@ -51,10 +51,11 @@ typedef struct xenoprof_buf {
uint64_t user_samples;
uint64_t lost_samples;
struct event_log event_log[1];
-} xenoprof_buf_t;
+};
+typedef struct xenoprof_buf xenoprof_buf_t;
DEFINE_XEN_GUEST_HANDLE(xenoprof_buf_t);
-typedef struct xenoprof_init {
+struct xenoprof_init {
int32_t max_samples;
int32_t num_events;
int32_t is_primary;
@@ -62,10 +63,11 @@ typedef struct xenoprof_init {
int32_t bufsize;
uint64_t buf_maddr;
char cpu_type[XENOPROF_CPU_TYPE_SIZE];
-} xenoprof_init_t;
+};
+typedef struct xenoprof_init xenoprof_init_t;
DEFINE_XEN_GUEST_HANDLE(xenoprof_init_t);
-typedef struct xenoprof_counter {
+struct xenoprof_counter {
uint32_t ind;
uint64_t count;
uint32_t enabled;
@@ -74,7 +76,8 @@ typedef struct xenoprof_counter {
uint32_t kernel;
uint32_t user;
uint64_t unit_mask;
-} xenoprof_counter_t;
+};
+typedef struct xenoprof_counter xenoprof_counter_t;
DEFINE_XEN_GUEST_HANDLE(xenoprof_counter_t);
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/xen/hypercall.h
--- a/xen/include/xen/hypercall.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/xen/hypercall.h Mon May 22 14:13:38 2006 -0600
@@ -80,7 +80,7 @@ do_vcpu_op(
extern long
do_acm_op(
- XEN_GUEST_HANDLE(acm_op_t) u_acm_op);
+ int cmd, XEN_GUEST_HANDLE(void) arg);
extern long
do_nmi_op(
diff -r fbf676a36ee4 -r 72c5d8206d48 xen/include/xen/sched.h
--- a/xen/include/xen/sched.h Mon May 22 08:53:26 2006 -0600
+++ b/xen/include/xen/sched.h Mon May 22 14:13:38 2006 -0600
@@ -173,6 +173,7 @@ struct domain_setup_info
unsigned long v_kernend;
unsigned long v_kernentry;
/* Initialised by loader: Private. */
+ unsigned long elf_paddr_offset;
unsigned int load_symtab;
unsigned long symtab_addr;
unsigned long symtab_len;
diff -r fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/include/asm-x86_64/e820.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/include/asm-x86_64/e820.h Mon May 22 14:13:38
2006 -0600
@@ -0,0 +1,63 @@
+/*
+ * structures and definitions for the int 15, ax=e820 memory map
+ * scheme.
+ *
+ * In a nutshell, setup.S populates a scratch table in the
+ * empty_zero_block that contains a list of usable address/size
+ * duples. setup.c, this information is transferred into the e820map,
+ * and in init.c/numa.c, that new information is used to mark pages
+ * reserved or not.
+ */
+#ifndef __E820_HEADER
+#define __E820_HEADER
+
+#include <linux/mmzone.h>
+
+#define E820MAP 0x2d0 /* our map */
+#define E820MAX 128 /* number of entries in E820MAP */
+#define E820NR 0x1e8 /* # entries in E820MAP */
+
+#define E820_RAM 1
+#define E820_RESERVED 2
+#define E820_ACPI 3 /* usable as RAM once ACPI tables have been read */
+#define E820_NVS 4
+
+#define HIGH_MEMORY (1024*1024)
+
+#define LOWMEMSIZE() (0x9f000)
+
+#ifndef __ASSEMBLY__
+struct e820entry {
+ u64 addr; /* start of memory segment */
+ u64 size; /* size of memory segment */
+ u32 type; /* type of memory segment */
+} __attribute__((packed));
+
+struct e820map {
+ int nr_map;
+ struct e820entry map[E820MAX];
+};
+
+extern unsigned long find_e820_area(unsigned long start, unsigned long end,
+ unsigned size);
+extern void add_memory_region(unsigned long start, unsigned long size,
+ int type);
+extern void setup_memory_region(void);
+extern void contig_e820_setup(void);
+extern unsigned long e820_end_of_ram(void);
+extern void e820_reserve_resources(struct e820entry *e820, int nr_map);
+extern void e820_print_map(char *who);
+extern int e820_mapped(unsigned long start, unsigned long end, unsigned type);
+
+extern void e820_bootmem_free(pg_data_t *pgdat, unsigned long start,unsigned
long end);
+extern void e820_setup_gap(struct e820entry *e820, int nr_map);
+extern unsigned long e820_hole_size(unsigned long start_pfn,
+ unsigned long end_pfn);
+
+extern void __init parse_memopt(char *p, char **end);
+extern void __init parse_memmapopt(char *p, char **end);
+
+extern struct e820map e820;
+#endif/*!__ASSEMBLY__*/
+
+#endif/*__E820_HEADER*/
diff -r fbf676a36ee4 -r 72c5d8206d48 patches/linux-2.6.16.13/xen-hotplug.patch
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/linux-2.6.16.13/xen-hotplug.patch Mon May 22 14:13:38 2006 -0600
@@ -0,0 +1,11 @@
+--- ../pristine-linux-2.6.16.13/fs/proc/proc_misc.c 2006-05-02
22:38:44.000000000 +0100
++++ ./fs/proc/proc_misc.c 2006-05-22 15:29:34.000000000 +0100
+@@ -433,7 +433,7 @@ static int show_stat(struct seq_file *p,
+ (unsigned long long)cputime64_to_clock_t(irq),
+ (unsigned long long)cputime64_to_clock_t(softirq),
+ (unsigned long long)cputime64_to_clock_t(steal));
+- for_each_online_cpu(i) {
++ for_each_cpu(i) {
+
+ /* Copy values here to work around gcc-2.95.3, gcc-2.96 */
+ user = kstat_cpu(i).cpustat.user;
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/ioemu/hw/acpi.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/ioemu/hw/acpi.c Mon May 22 14:13:38 2006 -0600
@@ -0,0 +1,178 @@
+/*
+ * ACPI emulation
+ *
+ * Copyright (c) 2006 Virtual Iron Software
+ *
+ * This module provides the beginnings of some ACPI emulation.
+ * Initially, this code handles writes to the sleep state
+ * registers. This is done to detect requests to power-off
+ * a guest domain.
+ *
+ * Later, and driven by empirical evidence, additional capabilities
+ * and emulation might be added.
+ *
+ * Currently, the FADT specifies a small register set, of which
+ * only PM1_CNTa is available. In addition, the ASL code specifies
+ * the proper values to write on an S5 (poweroff) request, which
+ * this code understands.
+ *
+ */
+
+#include "vl.h"
+extern FILE* logfile;
+
+// Define some basic offsets to ACPI registers
+
+//#define DEBUG_ACPI
+#define PM1a_STS 0x0
+#define PM1a_EN 0x1
+#define PM1b_STS 0x2
+#define PM1b_EN 0x3
+#define PM1_CNTa 0x4
+#define PM1_CNTb 0x6
+
+// Values within PM1_CNTa that we need for power handling
+
+#define SLP_TYP_MASK 0x1C00
+#define SLP_VAL 0x1C00
+#define SLP_EN 0x2000
+
+// Base ACPI register address
+
+static unsigned int acpi_base = 0;
+
+/* acpi_write_byte - handle byte writes for ACPI I/O region
+ *
+ * Input:
+ * opaque pointer to private data structure (currently NULL)
+ * addr I/O space address to be written
+ * data data to be written
+ *
+ * Output:
+ * none
+ *
+ * Returns:
+ * none
+ */
+
+static void acpi_write_byte(void *opaque, uint32_t addr, uint32_t data) {
+
+#ifdef DEBUG_ACPI
+ fprintf(logfile, "%s - addr 0x%x, data 0x%x\n", __FUNCTION__, addr, data);
+#endif
+
+ // All byte writes are currently ignored
+
+ return;
+}
+
+/* acpi_write_word - handle word writes for ACPI I/O region
+ *
+ * Input:
+ * opaque pointer to private data structure (currently NULL)
+ * addr I/O space address to be written
+ * data data to be written
+ *
+ * Output:
+ * none
+ *
+ * Returns:
+ * none
+ */
+
+static void acpi_write_word(void *opaque, uint32_t addr, uint32_t data) {
+
+#ifdef DEBUG_ACPI
+ fprintf(logfile, "%s - addr 0x%x, data 0x%x\n", __FUNCTION__, addr, data);
+#endif
+
+ // Only a write to PM1_CNTa for power operations is handled
+ // All others are ignored
+
+ if (addr == acpi_base + PM1_CNTa) {
+ if ( ( (data & SLP_EN) != 0) &&
+ ( (data & SLP_TYP_MASK) == SLP_VAL) ) {
+ qemu_system_shutdown_request();
+ fprintf(logfile, "%s - ACPI Power State 5 (poweroff) requested\n",
__FUNCTION__);
+ }
+ }
+
+ return;
+}
+
+/* acpi_read_byte - handle byte reads for ACPI I/O region
+ *
+ * Input:
+ * opaque pointer to private data structure (currently NULL)
+ * addr I/O space address to be written
+ *
+ * Output:
+ * none
+ *
+ * Returns:
+ * data read
+ */
+
+static uint32_t acpi_read_byte(void *opaque, uint32_t addr) {
+
+#ifdef DEBUG_ACPI
+ fprintf(logfile, "%s - addr 0x%x\n", __FUNCTION__, addr);
+#endif
+
+ // All reads return 0
+
+ return 0;
+}
+
+/* acpi_read_word - handle word reads for ACPI I/O region
+ *
+ * Input:
+ * opaque pointer to private data structure (currently NULL)
+ * addr I/O space address to be written
+ *
+ * Output:
+ * none
+ *
+ * Returns:
+ * data read
+ */
+
+static uint32_t acpi_read_word(void *opaque, uint32_t addr) {
+
+#ifdef DEBUG_ACPI
+ fprintf(logfile, "%s - addr 0x%x\n", __FUNCTION__, addr);
+#endif
+
+ // All reads return 0
+
+ return 0;
+}
+
+/* acpi_init - initialize for ACPI I/O space operation handling
+ *
+ * Input:
+ * base base I/O address
+ *
+ * Output:
+ * none
+ *
+ * Returns:
+ * status
+ */
+
+int acpi_init(unsigned int base) {
+
+ fprintf(logfile, "%s - registering ACPI addresses at 0x%x\n",
__FUNCTION__, base);
+
+ // Map 16 bytes of reads/writes for bytes/words
+
+ register_ioport_write(base, 16, sizeof(unsigned char), acpi_write_byte,
NULL);
+ register_ioport_read(base, 16, sizeof(unsigned char), acpi_read_byte,
NULL);
+
+ register_ioport_write(base, 16, sizeof(unsigned short), acpi_write_word,
NULL);
+ register_ioport_read(base, 16, sizeof(unsigned short), acpi_read_word,
NULL);
+
+ acpi_base = base;
+
+ return 0;
+}
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/vtpm_manager/manager/vtpm_ipc.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/vtpm_manager/manager/vtpm_ipc.c Mon May 22 14:13:38 2006 -0600
@@ -0,0 +1,141 @@
+// ===================================================================
+//
+// Copyright (c) 2005, Intel Corp.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Intel Corporation nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+// OF THE POSSIBILITY OF SUCH DAMAGE.
+// ===================================================================
+//
+// vtpm_ipc.c Implements ipc routines using file io. This file can
+// be replaced with other ipc types.
+//
+// ===================================================================
+
+#include <sys/stat.h>
+#include "vtpm_ipc.h"
+#include "vtpmpriv.h"
+#include "log.h"
+
+int vtpm_ipc_init(vtpm_ipc_handle_t *ipc_h, char* name, int flags, BOOL
create) {
+ ipc_h->name = name;
+ ipc_h->flags = flags;
+ ipc_h->fh = VTPM_IPC_CLOSED;
+
+ if (create)
+ return(vtpm_ipc_create(ipc_h));
+ else
+ return 0;
+}
+
+// Create the file that needs opening. Used only for FIFOs
+// FYI: This may cause problems in other file IO schemes. We'll see.
+int vtpm_ipc_create(vtpm_ipc_handle_t *ipc_h) {
+ int fh;
+ struct stat file_info;
+
+ if ((!ipc_h) || (!ipc_h->name))
+ return -1;
+
+ if ( stat(ipc_h->name, &file_info) == -1) {
+ if ( mkfifo(ipc_h->name, S_IWUSR | S_IRUSR ) ) {
+ vtpmlogerror(VTPM_LOG_VTPM, "Failed to create fifo %s.\n", ipc_h->name);
+ return -1;
+ }
+ }
+
+ ipc_h->fh = VTPM_IPC_CLOSED;
+
+ return 0;
+}
+
+
+// Read size bytes. If FH isn't open, open it.
+int vtpm_ipc_read(vtpm_ipc_handle_t *ipc_h, vtpm_ipc_handle_t *alt_ipc_h, BYTE
*bytes, UINT32 size){
+ vtpm_ipc_handle_t *my_ipc_h;
+ int result;
+
+ if (ipc_h) {
+ my_ipc_h = ipc_h;
+ } else {
+ my_ipc_h = alt_ipc_h;
+ }
+
+ if (my_ipc_h->fh == VTPM_IPC_CLOSED) {
+ my_ipc_h->fh = open(my_ipc_h->name, my_ipc_h->flags);
+ }
+
+ if ( my_ipc_h->fh == VTPM_IPC_CLOSED ) {
+ vtpmlogerror(VTPM_LOG_VTPM, "VTPM ERROR: Can't open %s for reading.\n",
my_ipc_h->name);
+ return -1;
+ }
+
+ result = read(my_ipc_h->fh, bytes, size);
+ if (result < 0) {
+ my_ipc_h->fh = VTPM_IPC_CLOSED;
+ }
+
+ return (result);
+}
+
+// Write size bytes. If FH isn't open, open it.
+int vtpm_ipc_write(vtpm_ipc_handle_t *ipc_h, vtpm_ipc_handle_t *alt_ipc_h,
BYTE *bytes, UINT32 size) {
+ vtpm_ipc_handle_t *my_ipc_h;
+ int result;
+
+ if (ipc_h) {
+ my_ipc_h = ipc_h;
+ } else {
+ my_ipc_h = alt_ipc_h;
+ }
+
+ if (my_ipc_h->fh == VTPM_IPC_CLOSED) {
+ my_ipc_h->fh = open(my_ipc_h->name, my_ipc_h->flags);
+ }
+
+ if ( my_ipc_h->fh == VTPM_IPC_CLOSED ) {
+ vtpmlogerror(VTPM_LOG_VTPM, "VTPM ERROR: Can't open %s for writing.\n",
my_ipc_h->name);
+ return -1;
+ }
+
+ result = write(my_ipc_h->fh, bytes, size);
+ if (result < 0) {
+ my_ipc_h->fh = VTPM_IPC_CLOSED;
+ }
+
+ return (result);
+}
+
+// Mark file as closed and try and close it. Errors not reported.
+void vtpm_ipc_close(vtpm_ipc_handle_t *ipc_h) {
+
+ if (ipc_h) {
+ close(ipc_h->fh);
+ }
+ ipc_h->fh = VTPM_IPC_CLOSED;
+
+}
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/vtpm_manager/manager/vtpm_ipc.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/vtpm_manager/manager/vtpm_ipc.h Mon May 22 14:13:38 2006 -0600
@@ -0,0 +1,71 @@
+// ===================================================================
+//
+// Copyright (c) 2005, Intel Corp.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Intel Corporation nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+// OF THE POSSIBILITY OF SUCH DAMAGE.
+// ===================================================================
+//
+// vtpm_ipc.h Header for interprocess communication between VTPM manager
+// and Guests or VTPMs
+//
+// ===================================================================
+
+#ifndef __VTPM_IO_H__
+#define __VTPM_IO_H__
+
+#include "tcg.h"
+
+#define VTPM_IPC_CLOSED -1
+
+// Represents an (somewhat) abstracted io handle.
+typedef struct vtpm_ipc_handle_t {
+ int fh; // IO handle.
+ int flags; // Flags for opening. This may need to become
+ // a void *, but for now files use an int.
+ char *name; // Names for debugging as well as filenames
+ // for file-based io.
+} vtpm_ipc_handle_t;
+
+
+int vtpm_ipc_init(vtpm_ipc_handle_t *ioh, char* name, int flags, BOOL create);
+
+// Create the file that needs opening. Used only for FIFOs
+// FYI: This may cause problems in other file IO schemes. We'll see.
+int vtpm_ipc_create(vtpm_ipc_handle_t *ioh);
+
+// Read size bytes. If FH isn't open, open it.
+int vtpm_ipc_read(vtpm_ipc_handle_t *ioh, vtpm_ipc_handle_t *alt_ioh, BYTE
*bytes, UINT32 size);
+
+// Write size bytes. If FH isn't open, open it.
+int vtpm_ipc_write(vtpm_ipc_handle_t *ioh, vtpm_ipc_handle_t *alt_ioh, BYTE
*bytes, UINT32 size);
+
+// Mark file as closed and try and close it. Errors not reported.
+void vtpm_ipc_close(vtpm_ipc_handle_t *ioh);
+
+#endif
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/vtpm_manager/manager/vtpm_lock.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/vtpm_manager/manager/vtpm_lock.c Mon May 22 14:13:38 2006 -0600
@@ -0,0 +1,63 @@
+// ===================================================================
+//
+// Copyright (c) 2005, Intel Corp.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Intel Corporation nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+// OF THE POSSIBILITY OF SUCH DAMAGE.
+// ===================================================================
+//
+// vtpm_lock.c Provided controlled sync around access to vtpm structures
+//
+// ===================================================================
+
+#include <pthread.h>
+#include "vtpm_lock.h"
+
+static pthread_rwlock_t vtpm_lock;
+
+void vtpm_lock_init() {
+
+ pthread_rwlock_init( &vtpm_lock, NULL);
+}
+
+void vtpm_lock_destroy(){
+ pthread_rwlock_destroy(&vtpm_lock);
+}
+
+void vtpm_lock_rdlock(){
+ pthread_rwlock_rdlock(&vtpm_lock);
+}
+
+void vtpm_lock_wrlock(){
+ pthread_rwlock_wrlock(&vtpm_lock);
+}
+
+void vtpm_lock_unlock(){
+ pthread_rwlock_unlock(&vtpm_lock);
+}
+
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/vtpm_manager/manager/vtpm_lock.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/vtpm_manager/manager/vtpm_lock.h Mon May 22 14:13:38 2006 -0600
@@ -0,0 +1,48 @@
+// ===================================================================
+//
+// Copyright (c) 2005, Intel Corp.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Intel Corporation nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+// OF THE POSSIBILITY OF SUCH DAMAGE.
+// ===================================================================
+//
+// vtpm_lock.h Provided controlled sync around access to vtpm structures
+//
+// ===================================================================
+
+#ifndef __VTPM_LOCK_H__
+#define __VTPM_LOCK_H__
+
+void vtpm_lock_init();
+void vtpm_lock_destroy();
+
+void vtpm_lock_rdlock();
+void vtpm_lock_wrlock();
+void vtpm_lock_unlock();
+
+#endif
diff -r fbf676a36ee4 -r 72c5d8206d48
tools/vtpm_manager/manager/vtpm_manager_handler.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/vtpm_manager/manager/vtpm_manager_handler.c Mon May 22 14:13:38
2006 -0600
@@ -0,0 +1,455 @@
+// ===================================================================
+//
+// Copyright (c) 2005, Intel Corp.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Intel Corporation nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+// OF THE POSSIBILITY OF SUCH DAMAGE.
+// ===================================================================
+//
+// vtpm_manager_handler.c
+//
+// This file will house the main logic of the VTPM Manager
+//
+// ==================================================================
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "vtpm_manager.h"
+#include "vtpmpriv.h"
+#include "vtsp.h"
+#include "bsg.h"
+#include "hashtable.h"
+#include "hashtable_itr.h"
+#include "log.h"
+#include "buffer.h"
+
+#define vtpmhandlerloginfo(module,fmt,args...) vtpmloginfo (module, "[%s]: "
fmt, thread_name, ##args );
+#define vtpmhandlerloginfomore(module,fmt,args...) vtpmloginfomore (module,
fmt, ##args );
+#define vtpmhandlerlogerror(module,fmt,args...) vtpmlogerror (module, "[%s]: "
fmt, thread_name, ##args );
+
+// ---------------------- Prototypes -------------------
+TPM_RESULT vtpm_manager_handle_vtpm_cmd(VTPM_DMI_RESOURCE *dmi_res,
+ TPM_COMMAND_CODE ord,
+ buffer_t *command_buf,
+ buffer_t *result_buf,
+ BOOL is_priv,
+ char *thread_name);
+
+TPM_RESULT vtpm_manager_handle_tpm_cmd(vtpm_ipc_handle_t *tx_ipc_h,
+ vtpm_ipc_handle_t *rx_ipc_h,
+ VTPM_DMI_RESOURCE *dmi_res,
+ BYTE *cmd_header,
+ buffer_t *param_buf,
+ buffer_t *result_buf,
+ char *thread_name);
+
+TPM_RESULT VTPM_Manager_Handler( vtpm_ipc_handle_t *tx_ipc_h,
+ vtpm_ipc_handle_t *rx_ipc_h,
+ BOOL fw_tpm, // Forward TPM cmds?
+ vtpm_ipc_handle_t *fw_tx_ipc_h,
+ vtpm_ipc_handle_t *fw_rx_ipc_h,
+ BOOL is_priv,
+ char *thread_name) {
+ TPM_RESULT status = TPM_FAIL; // Should never return
+ UINT32 dmi, in_param_size, cmd_size, out_param_size,
out_message_size, out_message_size_full;
+ BYTE *cmd_header, *in_param, *out_message;
+ buffer_t *command_buf=NULL, *result_buf=NULL;
+ TPM_TAG tag;
+ TPM_COMMAND_CODE ord;
+ VTPM_DMI_RESOURCE *dmi_res;
+ int size_read, size_write, i;
+
+ cmd_header = (BYTE *) malloc(VTPM_COMMAND_HEADER_SIZE_SRV);
+ command_buf = (buffer_t *) malloc(sizeof(buffer_t));
+ result_buf = (buffer_t *) malloc(sizeof(buffer_t));
+
+ // ------------------------ Main Loop --------------------------------
+ while(1) {
+
+ vtpmhandlerloginfo(VTPM_LOG_VTPM, "%s waiting for messages.\n",
thread_name);
+
+ // --------------------- Read Cmd from Sender ----------------
+
+ // Read command header
+ size_read = vtpm_ipc_read(rx_ipc_h, NULL, cmd_header,
VTPM_COMMAND_HEADER_SIZE_SRV);
+ if (size_read > 0) {
+ vtpmhandlerloginfo(VTPM_LOG_VTPM_DEEP, "RECV[%d}: 0x", size_read);
+ for (i=0; i<size_read; i++)
+ vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "%x ", cmd_header[i]);
+ } else {
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "%s can't read from ipc. Aborting...
\n", thread_name);
+ goto abort_command;
+ }
+
+ if (size_read < (int) VTPM_COMMAND_HEADER_SIZE_SRV) {
+ vtpmhandlerloginfo(VTPM_LOG_VTPM_DEEP, "\n");
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "Command shorter than normal header
(%d bytes). Aborting...\n", size_read);
+ goto abort_command;
+ }
+
+ // Unpack header
+ BSG_UnpackList(cmd_header, 4,
+ BSG_TYPE_UINT32, &dmi,
+ BSG_TPM_TAG, &tag,
+ BSG_TYPE_UINT32, &in_param_size,
+ BSG_TPM_COMMAND_CODE, &ord );
+
+ // Using the header info, read the parameters of the command
+ // Note that in_param_size is in the client's context
+ cmd_size = in_param_size - VTPM_COMMAND_HEADER_SIZE_CLT;
+ if (cmd_size > 0) {
+ in_param = (BYTE *) malloc(cmd_size);
+ size_read = vtpm_ipc_read( rx_ipc_h, NULL, in_param, cmd_size);
+ if (size_read > 0) {
+ for (i=0; i<size_read; i++)
+ vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "%x ", in_param[i]);
+
+ } else {
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "%s had error reading cmd from ipc.
Aborting... \n", thread_name);
+ goto abort_command;
+ }
+ vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "\n");
+
+ if (size_read < (int) cmd_size) {
+ vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "\n");
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "Command read(%d) is shorter than
header indicates(%d). Aborting...\n", size_read, cmd_size);
+ goto abort_command;
+ }
+ } else {
+ in_param = NULL;
+ vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "\n");
+ }
+
+ // Init the buffers used to handle the command and the response
+ if ( (buffer_init_convert(command_buf, cmd_size, in_param) != TPM_SUCCESS)
||
+ (buffer_init(result_buf, 0, 0) != TPM_SUCCESS) ) {
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "Failed to setup buffers.
Aborting...\n");
+ goto abort_command;
+ }
+
+ // -------------- Dispatch Commands to Handlers -----------
+ if ((tag == VTPM_TAG_REQ) && (ord & VTPM_PRIV_MASK)) {
+ vtpm_lock_wrlock();
+ } else {
+ vtpm_lock_rdlock();
+ }
+
+ if ( !(dmi_res = (VTPM_DMI_RESOURCE *)
hashtable_search(vtpm_globals->dmi_map, &dmi)) ||
+ (!dmi_res->connected) ) {
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "Attempted access to non-existent or
disconnected DMI %d. Aborting...\n", dmi);
+ status = TPM_BAD_PARAMETER;
+ }
+
+ if (tag == VTPM_TAG_REQ) {
+
+ status = vtpm_manager_handle_vtpm_cmd(dmi_res, ord, command_buf,
result_buf, is_priv, thread_name);
+
+ } else { // This is not a VTPM Command at all.
+ if (fw_tpm) {
+ status = vtpm_manager_handle_tpm_cmd(fw_tx_ipc_h, fw_rx_ipc_h,
dmi_res, cmd_header, command_buf, result_buf, thread_name);
+
+ // This means calling the DMI failed, not that the cmd failed in the
DMI
+ if (status != TPM_SUCCESS) {
+ goto abort_with_error;
+ }
+ } else {
+ // We are not supposed to forward TPM commands at all.
+ int i;
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "Attempt to use unsupported direct
access to TPM.\n");
+ vtpmhandlerloginfo(VTPM_LOG_VTPM_DEEP, "Bad Command. dmi:%d, tag:%d,
size:%d, ord:%d, Params: ", dmi, tag, in_param_size, ord);
+ for (i=0; i<cmd_size; i++)
+ vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "%x ", in_param[i]);
+
+ vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "\n");
+
+ status = TPM_FAIL;
+ goto abort_with_error;
+ }
+
+ } // end else for is VTPM Command
+
+ // ------------------- Respond to Sender ------------------
+
+ // Errors while handling responses jump here to reply with error messages
+ // NOTE: Currently there are no recoverable errors in multi-VM mode. If one
+ // is added to the code, this ifdef should be removed.
+ // Also note this is NOT referring to errors in commands, but rather
+ // this is about I/O errors and such.
+#ifndef VTPM_MULTI_VM
+ abort_with_error:
+#endif
+
+ // Prepend VTPM header with destination DM stamped
+ out_param_size = buffer_len(result_buf);
+ out_message_size = VTPM_COMMAND_HEADER_SIZE_CLT + out_param_size;
+ out_message_size_full = VTPM_COMMAND_HEADER_SIZE_SRV + out_param_size;
+ out_message = (BYTE *) malloc (out_message_size_full);
+
+ BSG_PackList(out_message, 4,
+ BSG_TYPE_UINT32, (BYTE *) &dmi,
+ BSG_TPM_TAG, (BYTE *) &tag,
+ BSG_TYPE_UINT32, (BYTE *) &out_message_size,
+ BSG_TPM_RESULT, (BYTE *) &status);
+
+ if (buffer_len(result_buf) > 0)
+ memcpy(out_message + VTPM_COMMAND_HEADER_SIZE_SRV, result_buf->bytes,
out_param_size);
+
+ //Note: Send message + dmi_id
+ size_write = vtpm_ipc_write(tx_ipc_h, dmi_res->tx_vtpm_ipc_h, out_message,
out_message_size_full );
+ if (size_write > 0) {
+ vtpmhandlerloginfo(VTPM_LOG_VTPM_DEEP, "SENT: 0x");
+ for (i=0; i < out_message_size_full; i++)
+ vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "%x ", out_message[i]);
+
+ vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "\n");
+ } else {
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "%s had error writing to ipc.
Aborting... \n", thread_name);
+ goto abort_command;
+ }
+ free(out_message);
+
+ if (size_write < (int)out_message_size_full) {
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "%s unable to write full command to
ipc (%d/%d)\n", thread_name, size_write, out_message_size_full);
+ goto abort_command;
+ }
+
+ // On certain failures an error message cannot be sent.
+ // This marks the beginning of cleanup in preperation for the next command.
+ abort_command:
+ //free buffers
+ bzero(cmd_header, VTPM_COMMAND_HEADER_SIZE_SRV);
+ //free(in_param); // This was converted to command_buf. No need to free
+ if (command_buf != result_buf)
+ buffer_free(result_buf);
+
+ buffer_free(command_buf);
+
+ // If we have a write lock, save the manager table
+ if ((tag == VTPM_TAG_REQ) && (ord & VTPM_PRIV_MASK) &&
+ (VTPM_SaveManagerData() != TPM_SUCCESS) ) {
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "ERROR: Unable to save manager
data.\n");
+ }
+
+ vtpm_lock_unlock();
+ } // End while(1)
+
+}
+
+/////////////////////////////////////////////////////////////////////////
+TPM_RESULT vtpm_manager_handle_vtpm_cmd(VTPM_DMI_RESOURCE *dmi_res,
+ TPM_COMMAND_CODE ord,
+ buffer_t *command_buf,
+ buffer_t *result_buf,
+ BOOL is_priv,
+ char *thread_name) {
+
+ TPM_RESULT status = TPM_FAIL;
+
+ switch (ord) {
+ case VTPM_ORD_SAVENVM:
+ status= VTPM_Handle_Save_NVM(dmi_res,
+ command_buf,
+ result_buf);
+ break;
+
+ case VTPM_ORD_LOADNVM:
+ status= VTPM_Handle_Load_NVM(dmi_res,
+ command_buf,
+ result_buf);
+ break;
+
+ case VTPM_ORD_TPMCOMMAND:
+ status= VTPM_Handle_TPM_Command(dmi_res,
+ command_buf,
+ result_buf);
+ break;
+
+ default:
+ // Privileged handlers can do maintanance
+ if (is_priv) {
+ switch (ord) {
+ case VTPM_ORD_OPEN:
+ status = VTPM_Handle_New_DMI(command_buf);
+ break;
+
+ case VTPM_ORD_CLOSE:
+ status = VTPM_Handle_Close_DMI(command_buf);
+ break;
+
+ case VTPM_ORD_DELETE:
+ status = VTPM_Handle_Delete_DMI(command_buf);
+ break;
+
+ default:
+ status = TPM_BAD_ORDINAL;
+ } // switch
+ } else { // is priv command
+
+ status = TPM_BAD_ORDINAL;
+ } // inner switch
+ } // outer switch
+
+ return(status);
+}
+
+/////////////////////////////////////////////////////////////////////
+TPM_RESULT vtpm_manager_handle_tpm_cmd(vtpm_ipc_handle_t *tx_ipc_h,
+ vtpm_ipc_handle_t *rx_ipc_h,
+ VTPM_DMI_RESOURCE *dmi_res,
+ BYTE *cmd_header,
+ buffer_t *param_buf,
+ buffer_t *result_buf,
+ char *thread_name) {
+
+ TPM_RESULT status = TPM_FAIL;
+ UINT32 dmi_dst;
+ TPM_COMMAND_CODE ord;
+ TPM_TAG tag_out;
+ UINT32 dmi_cmd_size, in_param_size, adj_param_size;
+ BYTE *dmi_cmd, *in_param;
+ int size_read, size_write, i;
+
+ //// Dom0 can't talk to the BE, so this must be a broken FE/BE or badness
+ if (dmi_res->dmi_id == VTPM_CTL_DM) {
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "Illegal use of TPM command from
dom0\n");
+ status = TPM_FAIL;
+ goto abort_with_error;
+ }
+
+ vtpmhandlerloginfo(VTPM_LOG_VTPM, "Forwarding command to DMI.\n");
+
+ //Forward TPM CMD stamped with dmi_id to DMI for handling
+ if (buffer_len(param_buf)) {
+ dmi_cmd = (BYTE *) malloc(VTPM_COMMAND_HEADER_SIZE_SRV +
buffer_len(param_buf));
+ dmi_cmd_size = VTPM_COMMAND_HEADER_SIZE_SRV + buffer_len(param_buf);
+ memcpy(dmi_cmd, cmd_header, VTPM_COMMAND_HEADER_SIZE_SRV);
+ memcpy(dmi_cmd + VTPM_COMMAND_HEADER_SIZE_SRV, param_buf->bytes,
buffer_len(param_buf));
+ size_write = vtpm_ipc_write(tx_ipc_h, dmi_res->tx_tpm_ipc_h, dmi_cmd,
dmi_cmd_size);
+
+ if (size_write > 0) {
+ vtpmhandlerloginfo(VTPM_LOG_VTPM_DEEP, "SENT (DMI): 0x");
+ for (i=0; i<VTPM_COMMAND_HEADER_SIZE_SRV + buffer_len(param_buf); i++) {
+ vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "%x ", dmi_cmd[i]);
+ }
+ vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "\n");
+ } else {
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "Error writing to DMI. Aborting...
\n");
+ status = TPM_IOERROR;
+ goto abort_with_error;
+ }
+ free(dmi_cmd);
+ } else {
+ dmi_cmd_size = VTPM_COMMAND_HEADER_SIZE_SRV;
+ size_write = vtpm_ipc_write(tx_ipc_h, dmi_res->tx_tpm_ipc_h, cmd_header,
VTPM_COMMAND_HEADER_SIZE_SRV );
+ if (size_write > 0) {
+ for (i=0; i<VTPM_COMMAND_HEADER_SIZE_SRV; i++)
+ vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "%x ", cmd_header[i]);
+
+ vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "\n");
+ } else {
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "Error writing to DMI. Aborting...
\n");
+ status = TPM_IOERROR;
+ goto abort_with_error;
+ }
+ }
+
+ if (size_write != (int) dmi_cmd_size)
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "Could not write entire command to DMI
(%d/%d)\n", size_write, dmi_cmd_size);
+
+ buffer_free(param_buf);
+
+ // Read header for response to TPM command from DMI
+ size_read = vtpm_ipc_read( rx_ipc_h, dmi_res->rx_tpm_ipc_h, cmd_header,
VTPM_COMMAND_HEADER_SIZE_SRV);
+ if (size_read > 0) {
+ vtpmhandlerloginfo(VTPM_LOG_VTPM_DEEP, "RECV (DMI): 0x");
+ for (i=0; i<size_read; i++)
+ vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "%x ", cmd_header[i]);
+
+ } else {
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "Error reading from DMI. Aborting...
\n");
+ status = TPM_IOERROR;
+ goto abort_with_error;
+ }
+
+ if (size_read < (int) VTPM_COMMAND_HEADER_SIZE_SRV) {
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "Command from DMI shorter than normal
header. Aborting...\n");
+ status = TPM_IOERROR;
+ goto abort_with_error;
+ }
+
+ // Unpack response from DMI for TPM command
+ BSG_UnpackList(cmd_header, 4,
+ BSG_TYPE_UINT32, &dmi_dst,
+ BSG_TPM_TAG, &tag_out,
+ BSG_TYPE_UINT32, &in_param_size,
+ BSG_TPM_COMMAND_CODE, &status );
+
+ // If response has parameters, read them.
+ // Note that in_param_size is in the client's context
+ adj_param_size = in_param_size - VTPM_COMMAND_HEADER_SIZE_CLT;
+ if (adj_param_size > 0) {
+ in_param = (BYTE *) malloc(adj_param_size);
+ size_read = vtpm_ipc_read(rx_ipc_h, dmi_res->rx_tpm_ipc_h, in_param,
adj_param_size);
+ if (size_read > 0) {
+ for (i=0; i<size_read; i++)
+ vtpmhandlerloginfomore(VTPM_LOG_VTPM_DEEP, "%x ", in_param[i]);
+
+ } else {
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "Error reading from BE. Aborting...
\n");
+ goto abort_with_error;
+ }
+ vtpmhandlerloginfomore(VTPM_LOG_VTPM, "\n");
+
+ if (size_read < (int)adj_param_size) {
+ vtpmhandlerloginfomore(VTPM_LOG_VTPM, "\n");
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "Command read(%d) from DMI is shorter
than header indicates(%d). Aborting...\n", size_read, adj_param_size);
+ status = TPM_IOERROR;
+ goto abort_with_error;
+ }
+ } else {
+ in_param = NULL;
+ vtpmhandlerloginfomore(VTPM_LOG_VTPM, "\n");
+ }
+
+ if (buffer_init_convert(result_buf, adj_param_size, in_param) !=
TPM_SUCCESS) {
+ vtpmhandlerlogerror(VTPM_LOG_VTPM, "Failed to setup buffers.
Aborting...\n");
+ status = TPM_FAIL;
+ goto abort_with_error;
+ }
+
+ vtpmhandlerloginfo(VTPM_LOG_VTPM, "Sending DMI's response to guest.\n");
+
+ status = TPM_SUCCESS;
+
+ abort_with_error:
+
+ return status;
+}
+
diff -r fbf676a36ee4 -r 72c5d8206d48
tools/xm-test/tests/block-integrity/01_block_device_read_verify.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/xm-test/tests/block-integrity/01_block_device_read_verify.py
Mon May 22 14:13:38 2006 -0600
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2006
+# Author: Harry Butterworth <butterwo@xxxxxxxxxx>
+
+# This test initialises a ram disk in dom0 with data from /dev/urandom and
+# then imports the ram disk device as a physical device into a domU. The md5
+# checksum of the data in the ramdisk is calculated in dom0 and also
+# calculated by the domU reading the data through the blk frontend and
+# backend drivers. The test succeeds if the checksums match indicating that
+# the domU successfully read all the correct data from the device.
+
+import re
+
+from XmTestLib import *
+from XmTestLib.block_utils import *
+
+if ENABLE_HVM_SUPPORT:
+ SKIP("Block-attach not supported for HVM domains")
+
+domain = XmTestDomain()
+
+try:
+ console = domain.start()
+except DomainError, e:
+ FAIL(str(e))
+
+console.setHistorySaveCmds(value=True)
+
+traceCommand("cat /dev/urandom > /dev/ram1")
+
+s, o = traceCommand("md5sum /dev/ram1")
+
+dom0_md5sum_match = re.search(r"^[\dA-Fa-f]{32}", o)
+
+block_attach(domain, "phy:ram1", "hda1")
+
+try:
+ run = console.runCmd("md5sum /dev/hda1")
+except ConsoleError, e:
+ FAIL(str(e))
+
+domU_md5sum_match = re.search(r"^[\dA-Fa-f]{32}", run["output"])
+
+domain.closeConsole()
+
+domain.stop()
+
+if dom0_md5sum_match == None:
+ FAIL("Failed to get md5sum of test ram disk in dom0.")
+
+if domU_md5sum_match == None:
+ FAIL("Failed to get md5sum of test ram disk in domU.")
+
+if verbose:
+ print "md5sum dom0:"
+ print dom0_md5sum_match.group()
+ print "md5sum domU:"
+ print domU_md5sum_match.group()
+
+if dom0_md5sum_match.group() != domU_md5sum_match.group():
+ FAIL("MISCOMPARE: data read in domU did not match data provided by domO.")
diff -r fbf676a36ee4 -r 72c5d8206d48
tools/xm-test/tests/block-integrity/Makefile.am
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/xm-test/tests/block-integrity/Makefile.am Mon May 22 14:13:38
2006 -0600
@@ -0,0 +1,21 @@
+
+SUBDIRS =
+
+TESTS = 01_block_device_read_verify.test
+
+XFAIL_TESTS =
+
+EXTRA_DIST = $(TESTS) $(XFAIL_TESTS)
+
+TESTS_ENVIRONMENT=@TENV@
+
+%.test: %.py
+ cp $< $@
+ chmod +x $@
+
+clean-local: am_config_clean-local
+
+am_config_clean-local:
+ rm -f *test
+ rm -f *log
+ rm -f *~
diff -r fbf676a36ee4 -r 72c5d8206d48
tools/xm-test/tests/vtpm/05_vtpm-loc_migr.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/xm-test/tests/vtpm/05_vtpm-loc_migr.py Mon May 22 14:13:38
2006 -0600
@@ -0,0 +1,100 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2006
+# Author: Stefan Berger <stefanb@xxxxxxxxxx>
+
+# Positive Test: create domain with virtual TPM attached at build time,
+# check list of pcrs; locally migrate the domain and
+# check list of pcrs again
+# This test does local (non-live) migration.
+
+from XmTestLib import *
+from vtpm_utils import *
+import commands
+import os
+import os.path
+
+config = {"vtpm":"instance=1,backend=0"}
+domain = XmTestDomain(extraConfig=config)
+consoleHistory = ""
+
+try:
+ console = domain.start()
+except DomainError, e:
+ if verbose:
+ print e.extra
+ vtpm_cleanup(domain.getName())
+ FAIL("Unable to create domain")
+
+domName = domain.getName()
+
+try:
+ console.sendInput("input")
+except ConsoleError, e:
+ saveLog(console.getHistory())
+ vtpm_cleanup(domName)
+ FAIL(str(e))
+
+try:
+ run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
+except ConsoleError, e:
+ saveLog(console.getHistory())
+ vtpm_cleanup(domName)
+ FAIL(str(e))
+
+if re.search("No such file",run["output"]):
+ vtpm_cleanup(domName)
+ FAIL("TPM frontend support not compiled into (domU?) kernel")
+
+consoleHistory = console.getHistory()
+domain.closeConsole()
+
+old_domid = domid(domName)
+
+loop = 0
+while loop < 3:
+ try:
+ status, ouptut = traceCommand("xm migrate %s localhost" %
+ domName,
+ 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?")
+
+
+ domName = domain.getName()
+ 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/platform/tpm_vtpm/pcrs")
+ except ConsoleError, e:
+ saveLog(console.getHistory())
+ vtpm_cleanup(domName)
+ FAIL(str(e))
+ loop += 1
+
+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 fbf676a36ee4 -r 72c5d8206d48
linux-2.6-xen-sparse/arch/ia64/xen/xen_ksyms.c
--- a/linux-2.6-xen-sparse/arch/ia64/xen/xen_ksyms.c Mon May 22 08:53:26
2006 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/*
- * Architecture-specific kernel symbols
- *
- * Don't put any exports here unless it's defined in an assembler file.
- * All other exports should be put directly after the definition.
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-
-extern int is_running_on_xen(void);
-EXPORT_SYMBOL(is_running_on_xen);
diff -r fbf676a36ee4 -r 72c5d8206d48 tools/xentrace/tbctl.c
--- a/tools/xentrace/tbctl.c Mon May 22 08:53:26 2006 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <xenctrl.h>
-
-int main(int argc, char * argv[])
-{
- int enable;
- int xc_handle = xc_interface_open();
-
- if (argc < 2) {
- printf("usage: %s [0|1]\n", argv[0]);
- exit(1);
- }
- enable = atoi(argv[1]);
-
- if (xc_tbuf_enable(xc_handle, enable) != 0) {
- perror("Enable/Disable Hypercall failure");
- exit(1);
- }
- else
- printf("Tracing now %s\n", (enable ? "enabled" : "disabled"));
-
- xc_interface_close(xc_handle);
- return 0;
-}
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|