ia64/xen-unstable
changeset 11930:6492b9b27968
merge with xen-unstable.hg
author | awilliam@xenbuild.aw |
---|---|
date | Sun Oct 22 15:23:52 2006 -0600 (2006-10-22) |
parents | d5a46e4cc340 8113c55a6efd |
children | 901083dace1d |
files | tools/libxc/ia64/xc_ia64_linux_restore.c tools/libxc/ia64/xc_ia64_linux_save.c tools/misc/mbootpack/GPL tools/misc/mbootpack/Makefile tools/misc/mbootpack/README tools/misc/mbootpack/bin2c.c tools/misc/mbootpack/bootsect.S tools/misc/mbootpack/buildimage.c tools/misc/mbootpack/mb_header.h tools/misc/mbootpack/mb_info.h tools/misc/mbootpack/mbootpack.c tools/misc/mbootpack/mbootpack.h tools/misc/mbootpack/setup.S tools/security/example.txt tools/security/install.txt unmodified_drivers/linux-2.6/mkbuildtree xen/arch/ia64/Rules.mk |
line diff
1.1 --- a/.hgignore Sun Oct 22 14:39:15 2006 -0600 1.2 +++ b/.hgignore Sun Oct 22 15:23:52 2006 -0600 1.3 @@ -15,8 +15,11 @@ 1.4 .*\.rej$ 1.5 .*/a\.out$ 1.6 .*/cscope\..*$ 1.7 +^cscope.*$ 1.8 ^[^/]*\.bz2$ 1.9 +^\.config$ 1.10 ^TAGS$ 1.11 +^tags$ 1.12 ^dist/.*$ 1.13 ^docs/.*\.aux$ 1.14 ^docs/.*\.dvi$
2.1 --- a/.hgtags Sun Oct 22 14:39:15 2006 -0600 2.2 +++ b/.hgtags Sun Oct 22 15:23:52 2006 -0600 2.3 @@ -15,3 +15,4 @@ 3d330e41f41ce1bc118c02346e18949ad5d67f6b 2.4 c8fdb0caa77b429cf47f9707926e83947778cb48 RELEASE-3.0.0 2.5 af0573e9e5258db0a9d28aa954dd302ddd2c2d23 3.0.2-rc 2.6 d0d3fef37685be264a7f52201f8ef44c030daad3 3.0.2-branched 2.7 +6ed4368b4a9e1924c983774c4b1a2b6baf8e98a6 3.0.3-branched
3.1 --- a/Config.mk Sun Oct 22 14:39:15 2006 -0600 3.2 +++ b/Config.mk Sun Oct 22 15:23:52 2006 -0600 3.3 @@ -4,43 +4,21 @@ 3.4 debug ?= n 3.5 3.6 XEN_COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/ \ 3.7 - -e s/ppc/powerpc/) 3.8 + -e s/ppc/powerpc/ -e s/i86pc/x86_32/) 3.9 XEN_TARGET_ARCH ?= $(XEN_COMPILE_ARCH) 3.10 XEN_TARGET_X86_PAE ?= n 3.11 +XEN_OS ?= $(shell uname -s) 3.12 + 3.13 +CONFIG_$(XEN_OS) := y 3.14 3.15 # Tools to run on system hosting the build 3.16 HOSTCC = gcc 3.17 HOSTCFLAGS = -Wall -Werror -Wstrict-prototypes -O2 -fomit-frame-pointer 3.18 3.19 -AS = $(CROSS_COMPILE)as 3.20 -LD = $(CROSS_COMPILE)ld 3.21 -CC = $(CROSS_COMPILE)gcc 3.22 -CPP = $(CROSS_COMPILE)gcc -E 3.23 -AR = $(CROSS_COMPILE)ar 3.24 -RANLIB = $(CROSS_COMPILE)ranlib 3.25 -NM = $(CROSS_COMPILE)nm 3.26 -STRIP = $(CROSS_COMPILE)strip 3.27 -OBJCOPY = $(CROSS_COMPILE)objcopy 3.28 -OBJDUMP = $(CROSS_COMPILE)objdump 3.29 - 3.30 DISTDIR ?= $(XEN_ROOT)/dist 3.31 DESTDIR ?= / 3.32 3.33 -INSTALL = install 3.34 -INSTALL_DIR = $(INSTALL) -d -m0755 3.35 -INSTALL_DATA = $(INSTALL) -m0644 3.36 -INSTALL_PROG = $(INSTALL) -m0755 3.37 - 3.38 -ifneq ($(debug),y) 3.39 -# Optimisation flags are overridable 3.40 -CFLAGS ?= -O2 -fomit-frame-pointer 3.41 -CFLAGS += -DNDEBUG 3.42 -else 3.43 -# Less than -O1 produces bad code and large stack frames 3.44 -CFLAGS ?= -O1 -fno-omit-frame-pointer 3.45 -CFLAGS += -g 3.46 -endif 3.47 - 3.48 +include $(XEN_ROOT)/config/$(XEN_OS).mk 3.49 include $(XEN_ROOT)/config/$(XEN_TARGET_ARCH).mk 3.50 3.51 ifneq ($(EXTRA_PREFIX),) 3.52 @@ -48,19 +26,31 @@ EXTRA_INCLUDES += $(EXTRA_PREFIX)/includ 3.53 EXTRA_LIB += $(EXTRA_PREFIX)/$(LIBDIR) 3.54 endif 3.55 3.56 -test-gcc-flag = $(shell $(1) -v --help 2>&1 | grep -q " $(2) " && echo $(2)) 3.57 +# cc-option 3.58 +# Usage: cflags-y += $(call cc-option,$(CC),-march=winchip-c6,-march=i586) 3.59 +cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc \ 3.60 + /dev/null 2>&1`"; then echo "$(2)"; else echo "$(3)"; fi ;) 3.61 + 3.62 +ifneq ($(debug),y) 3.63 +CFLAGS += -DNDEBUG 3.64 +else 3.65 +CFLAGS += -g 3.66 +endif 3.67 + 3.68 +CFLAGS += -std=gnu99 3.69 3.70 CFLAGS += -Wall -Wstrict-prototypes 3.71 3.72 -HOSTCFLAGS += $(call test-gcc-flag,$(HOSTCC),-Wdeclaration-after-statement) 3.73 -CFLAGS += $(call test-gcc-flag,$(CC),-Wdeclaration-after-statement) 3.74 +# -Wunused-value makes GCC 4.x too aggressive for my taste: ignoring the 3.75 +# result of any casted expression causes a warning. 3.76 +CFLAGS += -Wno-unused-value 3.77 + 3.78 +HOSTCFLAGS += $(call cc-option,$(HOSTCC),-Wdeclaration-after-statement,) 3.79 +CFLAGS += $(call cc-option,$(CC),-Wdeclaration-after-statement,) 3.80 3.81 LDFLAGS += $(foreach i, $(EXTRA_LIB), -L$(i)) 3.82 CFLAGS += $(foreach i, $(EXTRA_INCLUDES), -I$(i)) 3.83 3.84 -# Choose the best mirror to download linux kernel 3.85 -KERNEL_REPO = http://www.kernel.org 3.86 - 3.87 # If ACM_SECURITY = y, then the access control module is compiled 3.88 # into Xen and the policy type can be set by the boot policy file 3.89 # y - Build the Xen ACM framework
4.1 --- a/Makefile Sun Oct 22 14:39:15 2006 -0600 4.2 +++ b/Makefile Sun Oct 22 15:23:52 2006 -0600 4.3 @@ -2,11 +2,6 @@ 4.4 # Grand Unified Makefile for Xen. 4.5 # 4.6 4.7 -KERNELS ?= linux-2.6-xen 4.8 -# You may use wildcards in the above e.g. KERNELS=*2.6* 4.9 - 4.10 -XKERNELS := $(foreach kernel, $(KERNELS), $(patsubst buildconfigs/mk.%,%,$(wildcard buildconfigs/mk.$(kernel))) ) 4.11 - 4.12 # Export target architecture overrides to Xen and Linux sub-trees. 4.13 ifneq ($(XEN_TARGET_ARCH),) 4.14 SUBARCH := $(subst x86_32,i386,$(XEN_TARGET_ARCH))
5.1 --- a/buildconfigs/Rules.mk Sun Oct 22 14:39:15 2006 -0600 5.2 +++ b/buildconfigs/Rules.mk Sun Oct 22 15:23:52 2006 -0600 5.3 @@ -3,6 +3,9 @@ include Config.mk 5.4 5.5 export DESTDIR 5.6 5.7 +# Choose the best mirror to download linux kernel 5.8 +KERNEL_REPO = http://www.kernel.org 5.9 + 5.10 ALLKERNELS = $(patsubst buildconfigs/mk.%,%,$(wildcard buildconfigs/mk.*)) 5.11 ALLSPARSETREES = $(patsubst %-xen-sparse,%,$(wildcard *-xen-sparse)) 5.12
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/config/Linux.mk Sun Oct 22 15:23:52 2006 -0600 6.3 @@ -0,0 +1,8 @@ 6.4 +include $(XEN_ROOT)/config/StdGNU.mk 6.5 + 6.6 +# You may use wildcards, e.g. KERNELS=*2.6* 6.7 +KERNELS ?= linux-2.6-xen 6.8 + 6.9 +XKERNELS := $(foreach kernel, $(KERNELS), \ 6.10 + $(patsubst buildconfigs/mk.%,%, \ 6.11 + $(wildcard buildconfigs/mk.$(kernel))) )
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/config/OpenBSD.mk Sun Oct 22 15:23:52 2006 -0600 7.3 @@ -0,0 +1,1 @@ 7.4 +include $(XEN_ROOT)/config/StdGNU.mk
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/config/StdGNU.mk Sun Oct 22 15:23:52 2006 -0600 8.3 @@ -0,0 +1,30 @@ 8.4 +AS = $(CROSS_COMPILE)as 8.5 +LD = $(CROSS_COMPILE)ld 8.6 +CC = $(CROSS_COMPILE)gcc 8.7 +CPP = $(CROSS_COMPILE)gcc -E 8.8 +AR = $(CROSS_COMPILE)ar 8.9 +RANLIB = $(CROSS_COMPILE)ranlib 8.10 +NM = $(CROSS_COMPILE)nm 8.11 +STRIP = $(CROSS_COMPILE)strip 8.12 +OBJCOPY = $(CROSS_COMPILE)objcopy 8.13 +OBJDUMP = $(CROSS_COMPILE)objdump 8.14 + 8.15 +INSTALL = install 8.16 +INSTALL_DIR = $(INSTALL) -d -m0755 8.17 +INSTALL_DATA = $(INSTALL) -m0644 8.18 +INSTALL_PROG = $(INSTALL) -m0755 8.19 + 8.20 +LIB64DIR = lib64 8.21 + 8.22 +SOCKET_LIBS = 8.23 +CURSES_LIBS = -lncurses 8.24 +SONAME_LDFLAG = -soname 8.25 +SHLIB_CFLAGS = -shared 8.26 + 8.27 +ifneq ($(debug),y) 8.28 +# Optimisation flags are overridable 8.29 +CFLAGS ?= -O2 -fomit-frame-pointer 8.30 +else 8.31 +# Less than -O1 produces bad code and large stack frames 8.32 +CFLAGS ?= -O1 -fno-omit-frame-pointer 8.33 +endif
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/config/SunOS.mk Sun Oct 22 15:23:52 2006 -0600 9.3 @@ -0,0 +1,35 @@ 9.4 +AS = $(CROSS_COMPILE)gas 9.5 +LD = $(CROSS_COMPILE)gld 9.6 +CC = $(CROSS_COMPILE)gcc 9.7 +CPP = $(CROSS_COMPILE)gcc -E 9.8 +AR = $(CROSS_COMPILE)gar 9.9 +RANLIB = $(CROSS_COMPILE)granlib 9.10 +NM = $(CROSS_COMPILE)gnm 9.11 +STRIP = $(CROSS_COMPILE)gstrip 9.12 +OBJCOPY = $(CROSS_COMPILE)gobjcopy 9.13 +OBJDUMP = $(CROSS_COMPILE)gobjdump 9.14 + 9.15 +SHELL = bash 9.16 + 9.17 +INSTALL = ginstall 9.18 +INSTALL_DIR = $(INSTALL) -d -m0755 9.19 +INSTALL_DATA = $(INSTALL) -m0644 9.20 +INSTALL_PROG = $(INSTALL) -m0755 9.21 + 9.22 +LIB64DIR = lib/amd64 9.23 + 9.24 +SOCKET_LIBS = -lsocket 9.25 +CURSES_LIBS = -lcurses 9.26 +SONAME_LDFLAG = -h 9.27 +SHLIB_CFLAGS = -static-libgcc -shared 9.28 + 9.29 +ifneq ($(debug),y) 9.30 +# Optimisation flags are overridable 9.31 +CFLAGS ?= -O2 -fno-omit-frame-pointer 9.32 +else 9.33 +# Less than -O1 produces bad code and large stack frames 9.34 +CFLAGS ?= -O1 -fno-omit-frame-pointer 9.35 +endif 9.36 + 9.37 +CFLAGS += -Wa,--divide -D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ 9.38 +
10.1 --- a/config/ia64.mk Sun Oct 22 14:39:15 2006 -0600 10.2 +++ b/config/ia64.mk Sun Oct 22 15:23:52 2006 -0600 10.3 @@ -1,4 +1,6 @@ 10.4 CONFIG_IA64 := y 10.5 +CONFIG_IA64_$(XEN_OS) := y 10.6 + 10.7 CONFIG_IOEMU := y 10.8 CONFIG_XCUTILS := y 10.9
11.1 --- a/config/powerpc64.mk Sun Oct 22 14:39:15 2006 -0600 11.2 +++ b/config/powerpc64.mk Sun Oct 22 15:23:52 2006 -0600 11.3 @@ -1,4 +1,5 @@ 11.4 CONFIG_POWERPC := y 11.5 +CONFIG_POWERPC_$(XEN_OS) := y 11.6 11.7 CFLAGS += -DELFSIZE=64 11.8 LIBDIR := lib
12.1 --- a/config/x86_32.mk Sun Oct 22 14:39:15 2006 -0600 12.2 +++ b/config/x86_32.mk Sun Oct 22 15:23:52 2006 -0600 12.3 @@ -1,9 +1,17 @@ 12.4 CONFIG_X86 := y 12.5 +CONFIG_X86_$(XEN_OS) := y 12.6 + 12.7 CONFIG_HVM := y 12.8 CONFIG_MIGRATE := y 12.9 CONFIG_XCUTILS := y 12.10 CONFIG_IOEMU := y 12.11 -CONFIG_MBOOTPACK := y 12.12 12.13 CFLAGS += -m32 -march=i686 12.14 LIBDIR := lib 12.15 + 12.16 +# Use only if calling $(LD) directly. 12.17 +ifeq ($(XEN_OS),OpenBSD) 12.18 +LDFLAGS_DIRECT += -melf_i386_obsd 12.19 +else 12.20 +LDFLAGS_DIRECT += -melf_i386 12.21 +endif
13.1 --- a/config/x86_64.mk Sun Oct 22 14:39:15 2006 -0600 13.2 +++ b/config/x86_64.mk Sun Oct 22 15:23:52 2006 -0600 13.3 @@ -1,9 +1,17 @@ 13.4 CONFIG_X86 := y 13.5 +CONFIG_X86_$(XEN_OS) := y 13.6 + 13.7 CONFIG_HVM := y 13.8 CONFIG_MIGRATE := y 13.9 CONFIG_XCUTILS := y 13.10 CONFIG_IOEMU := y 13.11 -CONFIG_MBOOTPACK := y 13.12 13.13 CFLAGS += -m64 13.14 -LIBDIR = lib64 13.15 +LIBDIR = $(LIB64DIR) 13.16 + 13.17 +# Use only if calling $(LD) directly. 13.18 +ifeq ($(XEN_OS),OpenBSD) 13.19 +LDFLAGS_DIRECT += -melf_x86_64_obsd 13.20 +else 13.21 +LDFLAGS_DIRECT += -melf_x86_64 13.22 +endif
14.1 --- a/docs/Makefile Sun Oct 22 14:39:15 2006 -0600 14.2 +++ b/docs/Makefile Sun Oct 22 15:23:52 2006 -0600 14.3 @@ -1,8 +1,9 @@ 14.4 #!/usr/bin/make -f 14.5 14.6 +XEN_ROOT=.. 14.7 +include $(XEN_ROOT)/Config.mk 14.8 + 14.9 VERSION = xen-unstable 14.10 -INSTALL = install 14.11 -INSTALL_DIR = $(INSTALL) -d -m0755 14.12 14.13 PS2PDF := ps2pdf 14.14 DVIPS := dvips
15.1 --- a/docs/man/xm.pod.1 Sun Oct 22 14:39:15 2006 -0600 15.2 +++ b/docs/man/xm.pod.1 Sun Oct 22 15:23:52 2006 -0600 15.3 @@ -810,13 +810,13 @@ global policy root directory. 15.4 Loads the binary representation of the I<policy> into Xen. The binary 15.5 representation can be created with the B<makepolicy> subcommand. 15.6 15.7 -=item B<cfgbootpolicy> I<policy> [I<kernelversion>] 15.8 +=item B<cfgbootpolicy> I<policy> [I<boot title>] 15.9 15.10 Configures I<policy> as the boot policy for Xen. It copies the binary 15.11 policy representation into the /boot directory and adds a module line 15.12 specifying the binary policy to the /boot/grub/menu.lst file. If your 15.13 boot configuration includes multiple Xen boot titles, then use the 15.14 -I<kernelversion> parameter to select the proper title. 15.15 +I<boot title> parameter to specify a unique part of the proper title. 15.16 15.17 =item B<dumppolicy> 15.18
16.1 --- a/docs/src/interface.tex Sun Oct 22 14:39:15 2006 -0600 16.2 +++ b/docs/src/interface.tex Sun Oct 22 15:23:52 2006 -0600 16.3 @@ -955,7 +955,6 @@ This information doesn't change and is i 16.4 A {\bf /vm} entry contains the following information: 16.5 16.6 \begin{description} 16.7 -\item[ssidref] ssid reference for domain 16.8 \item[uuid] uuid of the domain (somewhat redundant) 16.9 \item[on\_reboot] the action to take on a domain reboot request (destroy or restart) 16.10 \item[on\_poweroff] the action to take on a domain halt request (destroy or restart) 16.11 @@ -1125,6 +1124,16 @@ This path contains: 16.12 \end{description} 16.13 \end{description} 16.14 16.15 + \item[security/] access control information for the domain 16.16 + \begin{description} 16.17 + \item[ssidref] security reference identifier used inside the hypervisor 16.18 + \item[access\_control/] security label used by management tools 16.19 + \begin{description} 16.20 + \item[label] security label name 16.21 + \item[policy] security policy name 16.22 + \end{description} 16.23 + \end{description} 16.24 + 16.25 \item[store/] per-domain information for the store 16.26 \begin{description} 16.27 \item[port] the event channel used for the store ring queue 16.28 @@ -2168,19 +2177,46 @@ Most of the above are best understood by 16.29 implementing them (in {\tt xen/common/dom0\_ops.c}) and in 16.30 the user-space tools that use them (mostly in {\tt tools/libxc}). 16.31 16.32 +\section{Access Control Module Hypercalls} 16.33 +\label{s:acmops} 16.34 + 16.35 Hypercalls relating to the management of the Access Control Module are 16.36 -also restricted to domain 0 access for now: 16.37 +also restricted to domain 0 access for now. For more details on any or 16.38 +all of these, please see {\tt xen/include/public/acm\_ops.h}. A 16.39 +complete list is given below: 16.40 16.41 \begin{quote} 16.42 16.43 -\hypercall{acm\_op(struct acm\_op * u\_acm\_op)} 16.44 +\hypercall{acm\_op(int cmd, void *args)} 16.45 16.46 This hypercall can be used to configure the state of the ACM, query 16.47 that state, request access control decisions and dump additional 16.48 information. 16.49 16.50 +\begin{description} 16.51 + 16.52 +\item [ACMOP\_SETPOLICY:] set the access control policy 16.53 + 16.54 +\item [ACMOP\_GETPOLICY:] get the current access control policy and 16.55 + status 16.56 + 16.57 +\item [ACMOP\_DUMPSTATS:] get current access control hook invocation 16.58 + statistics 16.59 + 16.60 +\item [ACMOP\_GETSSID:] get security access control information for a 16.61 + domain 16.62 + 16.63 +\item [ACMOP\_GETDECISION:] get access decision based on the currently 16.64 + enforced access control policy 16.65 + 16.66 +\end{description} 16.67 \end{quote} 16.68 16.69 +Most of the above are best understood by looking at the code 16.70 +implementing them (in {\tt xen/common/acm\_ops.c}) and in the 16.71 +user-space tools that use them (mostly in {\tt tools/security} and 16.72 +{\tt tools/python/xen/lowlevel/acm}). 16.73 + 16.74 16.75 \section{Debugging Hypercalls} 16.76
17.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/fixup.c Sun Oct 22 14:39:15 2006 -0600 17.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/fixup.c Sun Oct 22 15:23:52 2006 -0600 17.3 @@ -46,6 +46,9 @@ fastcall void do_fixup_4gb_segment(struc 17.4 if (test_and_set_bit(0, &printed)) 17.5 return; 17.6 17.7 + if (current->tgid == 1) /* Ignore statically linked init */ 17.8 + return; 17.9 + 17.10 HYPERVISOR_vm_assist( 17.11 VMASST_CMD_disable, VMASST_TYPE_4gb_segments_notify); 17.12
18.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c Sun Oct 22 14:39:15 2006 -0600 18.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c Sun Oct 22 15:23:52 2006 -0600 18.3 @@ -50,9 +50,6 @@ MODULE_LICENSE("GPL"); 18.4 18.5 /* no concurrent ->write()s are allowed on /dev/cpu/microcode */ 18.6 static DECLARE_MUTEX(microcode_sem); 18.7 - 18.8 -static void __user *user_buffer; /* user area microcode data buffer */ 18.9 -static unsigned int user_buffer_size; /* it's size */ 18.10 18.11 static int microcode_open (struct inode *unused1, struct file *unused2) 18.12 { 18.13 @@ -60,21 +57,26 @@ static int microcode_open (struct inode 18.14 } 18.15 18.16 18.17 -static int do_microcode_update (void) 18.18 +static int do_microcode_update (const void __user *ubuf, size_t len) 18.19 { 18.20 int err; 18.21 - dom0_op_t op; 18.22 + void *kbuf; 18.23 18.24 - err = sys_mlock((unsigned long)user_buffer, user_buffer_size); 18.25 - if (err != 0) 18.26 - return err; 18.27 + kbuf = vmalloc(len); 18.28 + if (!kbuf) 18.29 + return -ENOMEM; 18.30 + 18.31 + if (copy_from_user(kbuf, ubuf, len) == 0) { 18.32 + dom0_op_t op; 18.33 18.34 - op.cmd = DOM0_MICROCODE; 18.35 - set_xen_guest_handle(op.u.microcode.data, user_buffer); 18.36 - op.u.microcode.length = user_buffer_size; 18.37 - err = HYPERVISOR_dom0_op(&op); 18.38 + op.cmd = DOM0_MICROCODE; 18.39 + set_xen_guest_handle(op.u.microcode.data, kbuf); 18.40 + op.u.microcode.length = len; 18.41 + err = HYPERVISOR_dom0_op(&op); 18.42 + } else 18.43 + err = -EFAULT; 18.44 18.45 - (void)sys_munlock((unsigned long)user_buffer, user_buffer_size); 18.46 + vfree(kbuf); 18.47 18.48 return err; 18.49 } 18.50 @@ -88,17 +90,9 @@ static ssize_t microcode_write (struct f 18.51 return -EINVAL; 18.52 } 18.53 18.54 - if ((len >> PAGE_SHIFT) > num_physpages) { 18.55 - printk(KERN_ERR "microcode: too much data (max %ld pages)\n", num_physpages); 18.56 - return -EINVAL; 18.57 - } 18.58 - 18.59 down(µcode_sem); 18.60 18.61 - user_buffer = (void __user *) buf; 18.62 - user_buffer_size = (int) len; 18.63 - 18.64 - ret = do_microcode_update(); 18.65 + ret = do_microcode_update(buf, len); 18.66 if (!ret) 18.67 ret = (ssize_t)len; 18.68
19.1 --- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c Sun Oct 22 14:39:15 2006 -0600 19.2 +++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c Sun Oct 22 15:23:52 2006 -0600 19.3 @@ -343,6 +343,7 @@ static void backend_changed(struct xenbu 19.4 case XenbusStateInitialising: 19.5 case XenbusStateInitWait: 19.6 case XenbusStateInitialised: 19.7 + case XenbusStateUnknown: 19.8 break; 19.9 19.10 case XenbusStateConnected: 19.11 @@ -351,13 +352,14 @@ static void backend_changed(struct xenbu 19.12 19.13 case XenbusStateClosing: 19.14 tpmif_set_connected_state(tp, 0); 19.15 + xenbus_frontend_closed(dev); 19.16 break; 19.17 19.18 - case XenbusStateUnknown: 19.19 case XenbusStateClosed: 19.20 + tpmif_set_connected_state(tp, 0); 19.21 if (tp->is_suspended == 0) 19.22 device_unregister(&dev->dev); 19.23 - xenbus_switch_state(dev, XenbusStateClosed); 19.24 + xenbus_frontend_closed(dev); 19.25 break; 19.26 } 19.27 } 19.28 @@ -419,9 +421,10 @@ static int tpmfront_suspend(struct xenbu 19.29 mutex_lock(&suspend_lock); 19.30 tp->is_suspended = 1; 19.31 19.32 - for (ctr = 0; atomic_read(&tp->tx_busy) && ctr <= 25; ctr++) { 19.33 + for (ctr = 0; atomic_read(&tp->tx_busy) && ctr <= 300; ctr++) { 19.34 if ((ctr % 10) == 0) 19.35 - printk("TPM-FE [INFO]: Waiting for outstanding request.\n"); 19.36 + printk("TPM-FE [INFO]: Waiting for outstanding " 19.37 + "request.\n"); 19.38 /* 19.39 * Wait for a request to be responded to. 19.40 */
20.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c Sun Oct 22 14:39:15 2006 -0600 20.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c Sun Oct 22 15:23:52 2006 -0600 20.3 @@ -845,28 +845,29 @@ static void fast_flush_area(pending_req_ 20.4 uvaddr = MMAP_VADDR(info->user_vstart, u_idx, i); 20.5 20.6 khandle = &pending_handle(mmap_idx, k_idx, i); 20.7 - if (BLKTAP_INVALID_HANDLE(khandle)) { 20.8 - WPRINTK("BLKTAP_INVALID_HANDLE\n"); 20.9 - continue; 20.10 - } 20.11 - gnttab_set_unmap_op(&unmap[invcount], 20.12 - idx_to_kaddr(mmap_idx, k_idx, i), 20.13 - GNTMAP_host_map, khandle->kernel); 20.14 - invcount++; 20.15 20.16 - if (create_lookup_pte_addr( 20.17 - info->vma->vm_mm, 20.18 - MMAP_VADDR(info->user_vstart, u_idx, i), 20.19 - &ptep) !=0) { 20.20 - WPRINTK("Couldn't get a pte addr!\n"); 20.21 - return; 20.22 + if (khandle->kernel != 0xFFFF) { 20.23 + gnttab_set_unmap_op(&unmap[invcount], 20.24 + idx_to_kaddr(mmap_idx, k_idx, i), 20.25 + GNTMAP_host_map, khandle->kernel); 20.26 + invcount++; 20.27 } 20.28 20.29 - gnttab_set_unmap_op(&unmap[invcount], 20.30 - ptep, GNTMAP_host_map, 20.31 - khandle->user); 20.32 - invcount++; 20.33 - 20.34 + if (khandle->user != 0xFFFF) { 20.35 + if (create_lookup_pte_addr( 20.36 + info->vma->vm_mm, 20.37 + MMAP_VADDR(info->user_vstart, u_idx, i), 20.38 + &ptep) !=0) { 20.39 + WPRINTK("Couldn't get a pte addr!\n"); 20.40 + return; 20.41 + } 20.42 + 20.43 + gnttab_set_unmap_op(&unmap[invcount], 20.44 + ptep, GNTMAP_host_map, 20.45 + khandle->user); 20.46 + invcount++; 20.47 + } 20.48 + 20.49 BLKTAP_INVALIDATE_HANDLE(khandle); 20.50 } 20.51 ret = HYPERVISOR_grant_table_op( 20.52 @@ -1030,7 +1031,7 @@ static int print_dbug = 1; 20.53 static int do_block_io_op(blkif_t *blkif) 20.54 { 20.55 blkif_back_ring_t *blk_ring = &blkif->blk_ring; 20.56 - blkif_request_t *req; 20.57 + blkif_request_t req; 20.58 pending_req_t *pending_req; 20.59 RING_IDX rc, rp; 20.60 int more_to_do = 0; 20.61 @@ -1082,24 +1083,24 @@ static int do_block_io_op(blkif_t *blkif 20.62 break; 20.63 } 20.64 20.65 - req = RING_GET_REQUEST(blk_ring, rc); 20.66 + memcpy(&req, RING_GET_REQUEST(blk_ring, rc), sizeof(req)); 20.67 blk_ring->req_cons = ++rc; /* before make_response() */ 20.68 20.69 - switch (req->operation) { 20.70 + switch (req.operation) { 20.71 case BLKIF_OP_READ: 20.72 blkif->st_rd_req++; 20.73 - dispatch_rw_block_io(blkif, req, pending_req); 20.74 + dispatch_rw_block_io(blkif, &req, pending_req); 20.75 break; 20.76 20.77 case BLKIF_OP_WRITE: 20.78 blkif->st_wr_req++; 20.79 - dispatch_rw_block_io(blkif, req, pending_req); 20.80 + dispatch_rw_block_io(blkif, &req, pending_req); 20.81 break; 20.82 20.83 default: 20.84 WPRINTK("unknown operation [%d]\n", 20.85 - req->operation); 20.86 - make_response(blkif, req->id, req->operation, 20.87 + req.operation); 20.88 + make_response(blkif, req.id, req.operation, 20.89 BLKIF_RSP_ERROR); 20.90 free_req(pending_req); 20.91 break; 20.92 @@ -1128,9 +1129,10 @@ static void dispatch_rw_block_io(blkif_t 20.93 int usr_idx = GET_NEXT_REQ(info->idx_map); 20.94 uint16_t mmap_idx = pending_req->mem_idx; 20.95 20.96 - /*Check we have space on user ring - should never fail*/ 20.97 - if(usr_idx == INVALID_REQ) goto fail_flush; 20.98 - 20.99 + /* Check we have space on user ring - should never fail. */ 20.100 + if (usr_idx == INVALID_REQ) 20.101 + goto fail_response; 20.102 + 20.103 /* Check that number of segments is sane. */ 20.104 nseg = req->nr_segments; 20.105 if ( unlikely(nseg == 0) || 20.106 @@ -1195,8 +1197,6 @@ static void dispatch_rw_block_io(blkif_t 20.107 uvaddr, &ptep); 20.108 if (ret) { 20.109 WPRINTK("Couldn't get a pte addr!\n"); 20.110 - fast_flush_area(pending_req, pending_idx, usr_idx, 20.111 - blkif->dev_num); 20.112 goto fail_flush; 20.113 } 20.114 20.115 @@ -1224,19 +1224,25 @@ static void dispatch_rw_block_io(blkif_t 20.116 if (unlikely(map[i].status != 0)) { 20.117 WPRINTK("invalid kernel buffer -- " 20.118 "could not remap it\n"); 20.119 - goto fail_flush; 20.120 + ret |= 1; 20.121 + map[i].handle = 0xFFFF; 20.122 } 20.123 20.124 if (unlikely(map[i+1].status != 0)) { 20.125 WPRINTK("invalid user buffer -- " 20.126 "could not remap it\n"); 20.127 - goto fail_flush; 20.128 + ret |= 1; 20.129 + map[i+1].handle = 0xFFFF; 20.130 } 20.131 20.132 pending_handle(mmap_idx, pending_idx, i/2).kernel 20.133 = map[i].handle; 20.134 pending_handle(mmap_idx, pending_idx, i/2).user 20.135 = map[i+1].handle; 20.136 + 20.137 + if (ret) 20.138 + continue; 20.139 + 20.140 set_phys_to_machine(__pa(kvaddr) >> PAGE_SHIFT, 20.141 FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT)); 20.142 offset = (uvaddr - info->vma->vm_start) >> PAGE_SHIFT; 20.143 @@ -1244,6 +1250,10 @@ static void dispatch_rw_block_io(blkif_t 20.144 ((struct page **)info->vma->vm_private_data)[offset] = 20.145 pg; 20.146 } 20.147 + 20.148 + if (ret) 20.149 + goto fail_flush; 20.150 + 20.151 /* Mark mapped pages as reserved: */ 20.152 for (i = 0; i < req->nr_segments; i++) { 20.153 unsigned long kvaddr;
21.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c Sun Oct 22 14:39:15 2006 -0600 21.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c Sun Oct 22 15:23:52 2006 -0600 21.3 @@ -128,7 +128,7 @@ static struct ethtool_ops network_ethtoo 21.4 21.5 netif_t *netif_alloc(domid_t domid, unsigned int handle) 21.6 { 21.7 - int err = 0, i; 21.8 + int err = 0; 21.9 struct net_device *dev; 21.10 netif_t *netif; 21.11 char name[IFNAMSIZ] = {};
22.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Sun Oct 22 14:39:15 2006 -0600 22.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Sun Oct 22 15:23:52 2006 -0600 22.3 @@ -187,7 +187,7 @@ static struct sk_buff *netbk_copy_skb(st 22.4 if (unlikely(!nskb)) 22.5 goto err; 22.6 22.7 - skb_reserve(nskb, 16); 22.8 + skb_reserve(nskb, 16 + NET_IP_ALIGN); 22.9 headlen = nskb->end - nskb->data; 22.10 if (headlen > skb_headlen(skb)) 22.11 headlen = skb_headlen(skb); 22.12 @@ -1210,7 +1210,7 @@ static void net_tx_action(unsigned long 22.13 ret < MAX_SKB_FRAGS) ? 22.14 PKT_PROT_LEN : txreq.size; 22.15 22.16 - skb = alloc_skb(data_len+16, GFP_ATOMIC); 22.17 + skb = alloc_skb(data_len + 16 + NET_IP_ALIGN, GFP_ATOMIC); 22.18 if (unlikely(skb == NULL)) { 22.19 DPRINTK("Can't allocate a skb in start_xmit.\n"); 22.20 netbk_tx_err(netif, &txreq, i); 22.21 @@ -1218,7 +1218,7 @@ static void net_tx_action(unsigned long 22.22 } 22.23 22.24 /* Packets passed to netif_rx() must have some headroom. */ 22.25 - skb_reserve(skb, 16); 22.26 + skb_reserve(skb, 16 + NET_IP_ALIGN); 22.27 22.28 if (extras[XEN_NETIF_EXTRA_TYPE_GSO - 1].type) { 22.29 struct netif_extra_info *gso;
23.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Sun Oct 22 14:39:15 2006 -0600 23.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Sun Oct 22 15:23:52 2006 -0600 23.3 @@ -684,7 +684,7 @@ static void network_alloc_rx_buffers(str 23.4 * necessary here. 23.5 * 16 bytes added as necessary headroom for netif_receive_skb. 23.6 */ 23.7 - skb = alloc_skb(RX_COPY_THRESHOLD + 16, 23.8 + skb = alloc_skb(RX_COPY_THRESHOLD + 16 + NET_IP_ALIGN, 23.9 GFP_ATOMIC | __GFP_NOWARN); 23.10 if (unlikely(!skb)) 23.11 goto no_skb; 23.12 @@ -702,7 +702,7 @@ no_skb: 23.13 break; 23.14 } 23.15 23.16 - skb_reserve(skb, 16); /* mimic dev_alloc_skb() */ 23.17 + skb_reserve(skb, 16 + NET_IP_ALIGN); /* mimic dev_alloc_skb() */ 23.18 skb_shinfo(skb)->frags[0].page = page; 23.19 skb_shinfo(skb)->nr_frags = 1; 23.20 __skb_queue_tail(&np->rx_batch, skb); 23.21 @@ -2129,6 +2129,9 @@ module_init(netif_init); 23.22 23.23 static void __exit netif_exit(void) 23.24 { 23.25 + if (is_initial_xendomain()) 23.26 + return; 23.27 + 23.28 unregister_inetaddr_notifier(¬ifier_inetdev); 23.29 23.30 return xenbus_unregister_driver(&netfront);
24.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c Sun Oct 22 14:39:15 2006 -0600 24.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c Sun Oct 22 15:23:52 2006 -0600 24.3 @@ -157,10 +157,12 @@ static void frontend_changed(struct xenb 24.4 24.5 case XenbusStateClosing: 24.6 be->instance = -1; 24.7 + xenbus_switch_state(dev, XenbusStateClosing); 24.8 break; 24.9 24.10 - case XenbusStateUnknown: 24.11 + case XenbusStateUnknown: /* keep it here */ 24.12 case XenbusStateClosed: 24.13 + xenbus_switch_state(dev, XenbusStateClosed); 24.14 device_unregister(&be->dev->dev); 24.15 tpmback_remove(dev); 24.16 break;
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 25.2 +++ b/patches/linux-2.6.16.29/net-gso-5-rcv-mss.patch Sun Oct 22 15:23:52 2006 -0600 25.3 @@ -0,0 +1,13 @@ 25.4 +diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c 25.5 +index 104af5d..1fa1536 100644 25.6 +--- a/net/ipv4/tcp_input.c 25.7 ++++ b/net/ipv4/tcp_input.c 25.8 +@@ -127,7 +127,7 @@ static void tcp_measure_rcv_mss(struct s 25.9 + /* skb->len may jitter because of SACKs, even if peer 25.10 + * sends good full-sized frames. 25.11 + */ 25.12 +- len = skb->len; 25.13 ++ len = skb_shinfo(skb)->gso_size ?: skb->len; 25.14 + if (len >= icsk->icsk_ack.rcv_mss) { 25.15 + icsk->icsk_ack.rcv_mss = len; 25.16 + } else {
26.1 --- a/tools/Makefile Sun Oct 22 14:39:15 2006 -0600 26.2 +++ b/tools/Makefile Sun Oct 22 15:23:52 2006 -0600 26.3 @@ -60,7 +60,7 @@ check_clean: 26.4 $(MAKE) -C check clean 26.5 26.6 .PHONY: ioemu ioemuinstall ioemuclean 26.7 -ifdef CONFIG_IOEMU 26.8 +ifeq ($(CONFIG_IOEMU),y) 26.9 export IOEMU_DIR ?= ioemu 26.10 ioemu ioemuinstall: 26.11 [ -f $(IOEMU_DIR)/config-host.mak ] || \
27.1 --- a/tools/Rules.mk Sun Oct 22 14:39:15 2006 -0600 27.2 +++ b/tools/Rules.mk Sun Oct 22 15:23:52 2006 -0600 27.3 @@ -5,8 +5,6 @@ all: 27.4 27.5 include $(XEN_ROOT)/Config.mk 27.6 27.7 -CONFIG_$(shell uname -s) := y 27.8 - 27.9 XEN_XC = $(XEN_ROOT)/tools/python/xen/lowlevel/xc 27.10 XEN_LIBXC = $(XEN_ROOT)/tools/libxc 27.11 XEN_XENSTORE = $(XEN_ROOT)/tools/xenstore 27.12 @@ -25,9 +23,9 @@ CFLAGS += -D__XEN_TOOLS__ 27.13 %.o: %.cc 27.14 $(CC) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< 27.15 27.16 -OS = $(shell uname -s) 27.17 +.PHONY: mk-symlinks mk-symlinks-xen mk-symlinks-$(XEN_OS) 27.18 27.19 -.PHONY: mk-symlinks mk-symlinks-xen mk-symlinks-$(OS) 27.20 +mk-symlinks-SunOS: 27.21 27.22 mk-symlinks-Linux: LINUX_ROOT=$(XEN_ROOT)/linux-2.6-xen-sparse 27.23 mk-symlinks-Linux: 27.24 @@ -44,4 +42,4 @@ mk-symlinks-xen: 27.25 mkdir -p xen/io 27.26 ( cd xen/io && ln -sf ../../$(XEN_ROOT)/xen/include/public/io/*.h . ) 27.27 27.28 -mk-symlinks: mk-symlinks-xen mk-symlinks-$(OS) 27.29 +mk-symlinks: mk-symlinks-xen mk-symlinks-$(XEN_OS)
28.1 --- a/tools/blktap/drivers/Makefile Sun Oct 22 14:39:15 2006 -0600 28.2 +++ b/tools/blktap/drivers/Makefile Sun Oct 22 15:23:52 2006 -0600 28.3 @@ -3,11 +3,9 @@ include $(XEN_ROOT)/tools/Rules.mk 28.4 28.5 INCLUDES += -I.. -I../lib 28.6 28.7 -INSTALL = install 28.8 -INSTALL_PROG = $(INSTALL) -m0755 28.9 IBIN = blktapctrl tapdisk 28.10 QCOW_UTIL = img2qcow qcow2raw qcow-create 28.11 -INSTALL_DIR = /usr/sbin 28.12 +INST_DIR = /usr/sbin 28.13 LIBAIO_DIR = ../../libaio/src 28.14 28.15 CFLAGS += -Werror 28.16 @@ -58,7 +56,7 @@ img2qcow qcow2raw qcow-create: %: $(BLK- 28.17 $(CC) $(CFLAGS) -o $* $(BLK-OBJS) $*.c $(AIOLIBS) $(LIBS) 28.18 28.19 install: all 28.20 - $(INSTALL_PROG) $(IBIN) $(QCOW_UTIL) $(DESTDIR)$(INSTALL_DIR) 28.21 + $(INSTALL_PROG) $(IBIN) $(QCOW_UTIL) $(DESTDIR)$(INST_DIR) 28.22 28.23 clean: 28.24 rm -rf *.o *~ $(DEPS) xen TAGS $(IBIN) $(LIB) $(QCOW_UTIL)
29.1 --- a/tools/blktap/lib/Makefile Sun Oct 22 14:39:15 2006 -0600 29.2 +++ b/tools/blktap/lib/Makefile Sun Oct 22 15:23:52 2006 -0600 29.3 @@ -7,10 +7,6 @@ SONAME = libblktap.so.$(MAJOR) 29.4 29.5 BLKTAP_INSTALL_DIR = /usr/sbin 29.6 29.7 -INSTALL = install 29.8 -INSTALL_PROG = $(INSTALL) -m0755 29.9 -INSTALL_DIR = $(INSTALL) -d -m0755 29.10 - 29.11 INCLUDES += -I. -I.. -I $(XEN_LIBXC) -I $(XEN_XENSTORE) 29.12 29.13 LIBS := -lz 29.14 @@ -56,8 +52,8 @@ clean: 29.15 rm -rf *.a *.so* *.o *.rpm $(LIB) *~ $(DEPS) xen TAGS 29.16 29.17 libblktap.a: $(OBJS) 29.18 - $(CC) $(CFLAGS) -Wl,-soname -Wl,$(SONAME) -shared \ 29.19 - -L$(XEN_XENSTORE) -l xenstore \ 29.20 + $(CC) $(CFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,$(SONAME) $(SHLIB_CFLAGS) \ 29.21 + -L$(XEN_XENSTORE) -l xenstore \ 29.22 -o libblktap.so.$(MAJOR).$(MINOR) $^ $(LIBS) 29.23 ln -sf libblktap.so.$(MAJOR).$(MINOR) libblktap.so.$(MAJOR) 29.24 ln -sf libblktap.so.$(MAJOR) libblktap.so
30.1 --- a/tools/check/check_brctl Sun Oct 22 14:39:15 2006 -0600 30.2 +++ b/tools/check/check_brctl Sun Oct 22 15:23:52 2006 -0600 30.3 @@ -1,10 +1,27 @@ 30.4 -#!/bin/bash 30.5 +#!/bin/sh 30.6 # CHECK-INSTALL 30.7 30.8 -function error { 30.9 - echo 30.10 - echo ' *** Check for the bridge control utils (brctl) FAILED' 30.11 - exit 1 30.12 -} 30.13 +RC=0 30.14 30.15 -which brctl 1>/dev/null 2>&1 || error 30.16 +case ${OS} in 30.17 +OpenBSD|NetBSD|FreeBSD) 30.18 + # These systems have a bridge builtin 30.19 + TOOL="brconfig" 30.20 + which ${TOOL} 1>/dev/null 2>&1 || RC=1 30.21 + ;; 30.22 +Linux) 30.23 + TOOL="brctl" 30.24 + which ${TOOL} 1>/dev/null 2>&1 || RC=1 30.25 + ;; 30.26 +*) 30.27 + TOOL="" 30.28 + echo "Unknown OS" && RC=1 30.29 + ;; 30.30 +esac 30.31 + 30.32 +if test ${RC} -ne 0; then 30.33 + echo 30.34 + echo " *** Check for the bridge control utils (${TOOL}) FAILED" 30.35 +fi 30.36 + 30.37 +exit ${RC}
31.1 --- a/tools/check/check_iproute Sun Oct 22 14:39:15 2006 -0600 31.2 +++ b/tools/check/check_iproute Sun Oct 22 15:23:52 2006 -0600 31.3 @@ -1,11 +1,26 @@ 31.4 -#!/bin/bash 31.5 +#!/bin/sh 31.6 # CHECK-INSTALL 31.7 31.8 -function error { 31.9 - echo 31.10 - echo ' *** Check for iproute (ip addr) FAILED' 31.11 - exit 1 31.12 -} 31.13 +RC=0 31.14 31.15 -ip addr list 1>/dev/null 2>&1 || error 31.16 +case ${OS} in 31.17 +OpenBSD|NetBSD|FreeBSD) 31.18 + TOOL="ifconfig" 31.19 + eval ${TOOL} -a 1>/dev/null 2>&1 || RC=1 31.20 + ;; 31.21 +Linux) 31.22 + TOOL="ip addr" 31.23 + eval ${TOOL} list 1>/dev/null 2>&1 || RC=1 31.24 + ;; 31.25 +*) 31.26 + TOOL="" 31.27 + echo "Unknown OS" && RC=1 31.28 + ;; 31.29 +esac 31.30 31.31 +if test ${RC} -ne 0; then 31.32 + echo 31.33 + echo " *** Check for iproute (${TOOL}) FAILED" 31.34 +fi 31.35 + 31.36 +exit ${RC}
32.1 --- a/tools/check/check_python Sun Oct 22 14:39:15 2006 -0600 32.2 +++ b/tools/check/check_python Sun Oct 22 15:23:52 2006 -0600 32.3 @@ -1,10 +1,13 @@ 32.4 -#!/bin/bash 32.5 +#!/bin/sh 32.6 # CHECK-BUILD CHECK-INSTALL 32.7 32.8 -function error { 32.9 - echo 32.10 - echo " *** Check for Python version >= 2.2 FAILED" 32.11 - exit 1 32.12 -} 32.13 +RC=0 32.14 + 32.15 +python -V 2>&1 | cut -d ' ' -f 2 | grep -q '^2.[2345]' || RC=1 32.16 32.17 -python -V 2>&1 | cut -d ' ' -f 2 | grep -q '^2.[2345]' || error 32.18 +if test ${RC} -ne 0; then 32.19 + echo 32.20 + echo " *** Check for Python version >= 2.2 FAILED" 32.21 +fi 32.22 + 32.23 +exit ${RC}
33.1 --- a/tools/check/check_zlib_devel Sun Oct 22 14:39:15 2006 -0600 33.2 +++ b/tools/check/check_zlib_devel Sun Oct 22 15:23:52 2006 -0600 33.3 @@ -1,11 +1,14 @@ 33.4 -#!/bin/bash 33.5 +#!/bin/sh 33.6 # CHECK-BUILD 33.7 33.8 -function error { 33.9 - echo 33.10 - echo " *** Check for zlib headers FAILED" 33.11 - exit 1 33.12 -} 33.13 +RC=0 33.14 33.15 set -e 33.16 -[ -e /usr/include/zlib.h ] || error 33.17 +test -r /usr/include/zlib.h || RC=1 33.18 + 33.19 +if test ${RC} -ne 0; then 33.20 + echo 33.21 + echo " *** Check for zlib headers FAILED" 33.22 +fi 33.23 + 33.24 +exit ${RC}
34.1 --- a/tools/check/check_zlib_lib Sun Oct 22 14:39:15 2006 -0600 34.2 +++ b/tools/check/check_zlib_lib Sun Oct 22 15:23:52 2006 -0600 34.3 @@ -1,11 +1,14 @@ 34.4 -#!/bin/bash 34.5 +#!/bin/sh 34.6 # CHECK-BUILD CHECK-INSTALL 34.7 34.8 -function error { 34.9 - echo 34.10 - echo " *** Check for zlib library FAILED" 34.11 - exit 1 34.12 -} 34.13 +RC=0 34.14 34.15 set -e 34.16 -ldconfig -p | grep -q libz.so || error 34.17 +ldconfig -v 2>&1 | grep -q libz.so || RC=1 34.18 + 34.19 +if test ${RC} -ne 0; then 34.20 + echo 34.21 + echo " *** Check for zlib library FAILED" 34.22 +fi 34.23 + 34.24 +exit ${RC}
35.1 --- a/tools/check/chk Sun Oct 22 14:39:15 2006 -0600 35.2 +++ b/tools/check/chk Sun Oct 22 15:23:52 2006 -0600 35.3 @@ -1,8 +1,9 @@ 35.4 -#!/bin/bash 35.5 +#!/bin/sh 35.6 35.7 -function usage { 35.8 +func_usage () 35.9 +{ 35.10 echo "Usage:" 35.11 - echo "\t$0 [build|install|clean]" 35.12 + echo " $0 [build|install|clean]" 35.13 echo 35.14 echo "Check suitability for Xen build or install." 35.15 echo "Exit with 0 if OK, 1 if not." 35.16 @@ -12,7 +13,13 @@ function usage { 35.17 exit 1 35.18 } 35.19 35.20 -export PATH=${PATH}:/sbin:/usr/sbin 35.21 +PATH=${PATH}:/sbin:/usr/sbin 35.22 +OS=`uname -s` 35.23 +export PATH OS 35.24 + 35.25 +if test "${OS}" = "SunOS"; then 35.26 + exit 0 35.27 +fi 35.28 35.29 case $1 in 35.30 build) 35.31 @@ -25,7 +32,7 @@ case $1 in 35.32 exit 0 35.33 ;; 35.34 *) 35.35 - usage 35.36 + func_usage 35.37 ;; 35.38 esac 35.39 35.40 @@ -54,4 +61,4 @@ for f in check_* ; do 35.41 fi 35.42 done 35.43 35.44 -exit $failed 35.45 +exit ${failed}
36.1 --- a/tools/console/Makefile Sun Oct 22 14:39:15 2006 -0600 36.2 +++ b/tools/console/Makefile Sun Oct 22 15:23:52 2006 -0600 36.3 @@ -5,10 +5,6 @@ include $(XEN_ROOT)/tools/Rules.mk 36.4 DAEMON_INSTALL_DIR = /usr/sbin 36.5 CLIENT_INSTALL_DIR = /usr/$(LIBDIR)/xen/bin 36.6 36.7 -INSTALL = install 36.8 -INSTALL_PROG = $(INSTALL) -m0755 36.9 -INSTALL_DIR = $(INSTALL) -d -m0755 36.10 - 36.11 CFLAGS += -Werror -g 36.12 36.13 CFLAGS += -I $(XEN_LIBXC) 36.14 @@ -26,11 +22,11 @@ clean: 36.15 36.16 xenconsoled: $(patsubst %.c,%.o,$(wildcard daemon/*.c)) 36.17 $(CC) $(CFLAGS) $^ -o $@ -L$(XEN_LIBXC) -L$(XEN_XENSTORE) \ 36.18 - -lxenctrl -lxenstore 36.19 + $(SOCKET_LIBS) -lxenctrl -lxenstore 36.20 36.21 xenconsole: $(patsubst %.c,%.o,$(wildcard client/*.c)) 36.22 $(CC) $(CFLAGS) $^ -o $@ -L$(XEN_LIBXC) -L$(XEN_XENSTORE) \ 36.23 - -lxenctrl -lxenstore 36.24 + $(SOCKET_LIBS) -lxenctrl -lxenstore 36.25 36.26 .PHONY: install 36.27 install: $(BIN)
37.1 --- a/tools/console/daemon/io.c Sun Oct 22 14:39:15 2006 -0600 37.2 +++ b/tools/console/daemon/io.c Sun Oct 22 15:23:52 2006 -0600 37.3 @@ -147,7 +147,7 @@ static int domain_create_tty(struct doma 37.4 int master; 37.5 bool success; 37.6 37.7 - if ((master = getpt()) == -1 || 37.8 + if ((master = open("/dev/ptmx",O_RDWR|O_NOCTTY)) == -1 || 37.9 grantpt(master) == -1 || unlockpt(master) == -1) { 37.10 dolog(LOG_ERR, "Failed to create tty for domain-%d", 37.11 dom->domid);
38.1 --- a/tools/console/daemon/utils.c Sun Oct 22 14:39:15 2006 -0600 38.2 +++ b/tools/console/daemon/utils.c Sun Oct 22 15:23:52 2006 -0600 38.3 @@ -95,7 +95,7 @@ void daemonize(const char *pidfile) 38.4 exit(1); 38.5 } 38.6 38.7 - len = sprintf(buf, "%d\n", getpid()); 38.8 + len = sprintf(buf, "%ld\n", (long)getpid()); 38.9 if (write(fd, buf, len) < 0) 38.10 exit(1); 38.11
39.1 --- a/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c Sun Oct 22 14:39:15 2006 -0600 39.2 +++ b/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c Sun Oct 22 15:23:52 2006 -0600 39.3 @@ -36,8 +36,6 @@ 39.4 #include <unistd.h> 39.5 #include <errno.h> 39.6 #include <xenctrl.h> 39.7 -#include <thread_db.h> 39.8 -#include <xc_ptrace.h> 39.9 39.10 #define TRACE_ENTER /* printf("enter %s\n", __FUNCTION__) */ 39.11
40.1 --- a/tools/examples/Makefile Sun Oct 22 14:39:15 2006 -0600 40.2 +++ b/tools/examples/Makefile Sun Oct 22 15:23:52 2006 -0600 40.3 @@ -1,11 +1,6 @@ 40.4 XEN_ROOT = ../../ 40.5 include $(XEN_ROOT)/tools/Rules.mk 40.6 40.7 -INSTALL = install 40.8 -INSTALL_DIR = $(INSTALL) -d -m0755 40.9 -INSTALL_PROG = $(INSTALL) -m0755 40.10 -INSTALL_DATA = $(INSTALL) -m0644 40.11 - 40.12 # Init scripts. 40.13 XEND_INITD = init.d/xend 40.14 XENDOMAINS_INITD = init.d/xendomains
41.1 --- a/tools/examples/vtpm-common.sh Sun Oct 22 14:39:15 2006 -0600 41.2 +++ b/tools/examples/vtpm-common.sh Sun Oct 22 15:23:52 2006 -0600 41.3 @@ -226,7 +226,7 @@ function vtpmdb_remove_entry () { 41.4 # Returns 'resume' or 'create' 41.5 function vtpm_get_create_reason () { 41.6 local resume 41.7 - resume=$(xenstore-read $XENBUS_PATH/resume) 41.8 + resume=$(xenstore_read $XENBUS_PATH/resume) 41.9 if [ "$resume" == "True" ]; then 41.10 echo "resume" 41.11 else 41.12 @@ -287,6 +287,8 @@ function vtpm_create_instance () { 41.13 #entry is kept in the VTPMDB file. 41.14 function vtpm_remove_instance () { 41.15 local instance reason domname 41.16 + #Stop script execution quietly if path does not exist (anymore) 41.17 + xenstore-exists "$XENBUS_PATH"/domain 41.18 domname=$(xenstore_read "$XENBUS_PATH"/domain) 41.19 41.20 if [ "$domname" != "" ]; then 41.21 @@ -383,7 +385,7 @@ function vtpm_domid_from_name () { 41.22 local id name ids 41.23 ids=$(xenstore-list /local/domain) 41.24 for id in $ids; do 41.25 - name=$(xenstore-read /local/domain/$id/name) 41.26 + name=$(xenstore_read /local/domain/$id/name) 41.27 if [ "$name" == "$1" ]; then 41.28 echo "$id" 41.29 return
42.1 --- a/tools/examples/xend-config.sxp Sun Oct 22 14:39:15 2006 -0600 42.2 +++ b/tools/examples/xend-config.sxp Sun Oct 22 15:23:52 2006 -0600 42.3 @@ -135,3 +135,7 @@ 42.4 # to 127.0.0.1 To restore old 'listen everywhere' behaviour 42.5 # set this to 0.0.0.0 42.6 #(vnc-listen '127.0.0.1') 42.7 + 42.8 +# The default password for VNC console on HVM domain. 42.9 +# Empty string is no authentication. 42.10 +(vncpasswd '')
43.1 --- a/tools/examples/xmexample.hvm Sun Oct 22 14:39:15 2006 -0600 43.2 +++ b/tools/examples/xmexample.hvm Sun Oct 22 15:23:52 2006 -0600 43.3 @@ -150,6 +150,11 @@ vnc=1 43.4 #vncconsole=0 43.5 43.6 #---------------------------------------------------------------------------- 43.7 +# set password for domain's VNC console 43.8 +# default is depents on vncpasswd in xend-config.sxp 43.9 +vncpasswd='' 43.10 + 43.11 +#---------------------------------------------------------------------------- 43.12 # no graphics, use serial port 43.13 #nographic=0 43.14
44.1 --- a/tools/examples/xmexample.vti Sun Oct 22 14:39:15 2006 -0600 44.2 +++ b/tools/examples/xmexample.vti Sun Oct 22 15:23:52 2006 -0600 44.3 @@ -95,6 +95,11 @@ vnc=0 44.4 #vncconsole=0 44.5 44.6 #---------------------------------------------------------------------------- 44.7 +# set password for domain's VNC console 44.8 +# default is depents on vncpasswd in xend-config.sxp 44.9 +vncpasswd='' 44.10 + 44.11 +#---------------------------------------------------------------------------- 44.12 # no graphics, use serial port 44.13 #nographic=0 44.14
45.1 --- a/tools/firmware/Makefile Sun Oct 22 14:39:15 2006 -0600 45.2 +++ b/tools/firmware/Makefile Sun Oct 22 15:23:52 2006 -0600 45.3 @@ -4,7 +4,7 @@ include $(XEN_ROOT)/tools/Rules.mk 45.4 # hvmloader is a 32-bit protected mode binary. 45.5 # It belongs in /usr/lib, not /usr/lib64. 45.6 TARGET := hvmloader/hvmloader 45.7 -INSTALL_DIR := $(DESTDIR)/usr/lib/xen/boot 45.8 +INST_DIR := $(DESTDIR)/usr/lib/xen/boot 45.9 45.10 SUBDIRS := 45.11 SUBDIRS += rombios 45.12 @@ -29,8 +29,8 @@ all: 45.13 45.14 .PHONY: install 45.15 install: all 45.16 - [ -d $(INSTALL_DIR) ] || install -d -m0755 $(INSTALL_DIR) 45.17 - [ ! -e $(TARGET) ] || install -m0644 $(TARGET) $(INSTALL_DIR) 45.18 + [ -d $(INST_DIR) ] || $(INSTALL_DIR) $(INST_DIR) 45.19 + [ ! -e $(TARGET) ] || $(INSTALL_DATA) $(TARGET) $(INST_DIR) 45.20 45.21 .PHONY: clean 45.22 clean:
46.1 --- a/tools/firmware/acpi/Makefile Sun Oct 22 14:39:15 2006 -0600 46.2 +++ b/tools/firmware/acpi/Makefile Sun Oct 22 15:23:52 2006 -0600 46.3 @@ -53,7 +53,7 @@ iasl: 46.4 wget $(IASL_URL) 46.5 tar xzf $(IASL_VER).tar.gz 46.6 make -C $(IASL_VER)/compiler 46.7 - install $(IASL_VER)/compiler/iasl /usr/bin/iasl 46.8 + $(INSTALL_PROG) $(IASL_VER)/compiler/iasl /usr/bin/iasl 46.9 46.10 $(ACPI_GEN):$(C_SRC) $(H_SRC) acpi_dsdt.c 46.11 $(HOSTCC) -o $(ACPI_GEN) $(HOSTCFLAGS) $(shell ls *.c)
47.1 --- a/tools/firmware/hvmloader/Makefile Sun Oct 22 14:39:15 2006 -0600 47.2 +++ b/tools/firmware/hvmloader/Makefile Sun Oct 22 15:23:52 2006 -0600 47.3 @@ -32,13 +32,13 @@ DEFINES =-DDEBUG 47.4 XENINC =-I$(XEN_ROOT)/tools/libxc 47.5 47.6 # Disable PIE/SSP if GCC supports them. They can break us. 47.7 -CFLAGS += $(call test-gcc-flag,$(CC),-nopie) 47.8 -CFLAGS += $(call test-gcc-flag,$(CC),-fno-stack-protector) 47.9 -CFLAGS += $(call test-gcc-flag,$(CC),-fno-stack-protector-all) 47.10 +CFLAGS += $(call cc-option,$(CC),-nopie,) 47.11 +CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,) 47.12 +CFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,) 47.13 47.14 OBJCOPY = objcopy 47.15 CFLAGS += $(DEFINES) -I. $(XENINC) -fno-builtin -O2 -msoft-float 47.16 -LDFLAGS = -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,$(LOADADDR) 47.17 +LDFLAGS = -nostdlib -Wl,-N -Wl,-Ttext -Wl,$(LOADADDR) 47.18 47.19 SRCS = hvmloader.c acpi_madt.c mp_tables.c util.c smbios.c 47.20 OBJS = $(patsubst %.c,%.o,$(SRCS)) 47.21 @@ -48,7 +48,7 @@ all: hvmloader 47.22 47.23 hvmloader: roms.h $(SRCS) 47.24 $(CC) $(CFLAGS) -c $(SRCS) 47.25 - $(CC) $(LDFLAGS) -o hvmloader.tmp $(OBJS) 47.26 + $(CC) $(CFLAGS) $(LDFLAGS) -o hvmloader.tmp $(OBJS) 47.27 $(OBJCOPY) hvmloader.tmp hvmloader 47.28 rm -f hvmloader.tmp 47.29
48.1 --- a/tools/firmware/vmxassist/Makefile Sun Oct 22 14:39:15 2006 -0600 48.2 +++ b/tools/firmware/vmxassist/Makefile Sun Oct 22 15:23:52 2006 -0600 48.3 @@ -32,14 +32,13 @@ DEFINES=-DDEBUG -DTEXTADDR=$(TEXTADDR) 48.4 XENINC=-I$(XEN_ROOT)/tools/libxc 48.5 48.6 # Disable PIE/SSP if GCC supports them. They can break us. 48.7 -CFLAGS += $(call test-gcc-flag,$(CC),-nopie) 48.8 -CFLAGS += $(call test-gcc-flag,$(CC),-fno-stack-protector) 48.9 -CFLAGS += $(call test-gcc-flag,$(CC),-fno-stack-protector-all) 48.10 +CFLAGS += $(call cc-option,$(CC),-nopie,) 48.11 +CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,) 48.12 +CFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,) 48.13 48.14 CPP = cpp -P 48.15 OBJCOPY = objcopy -p -O binary -R .note -R .comment -R .bss -S --gap-fill=0 48.16 CFLAGS += $(DEFINES) -I. $(XENINC) -fno-builtin -O2 -msoft-float 48.17 -LDFLAGS = -m elf_i386 48.18 48.19 OBJECTS = head.o trap.o vm86.o setup.o util.o 48.20 48.21 @@ -48,7 +47,7 @@ all: vmxassist.bin 48.22 48.23 vmxassist.bin: vmxassist.ld $(OBJECTS) 48.24 $(CPP) $(DEFINES) vmxassist.ld > vmxassist.tmp 48.25 - $(LD) -o vmxassist $(LDFLAGS) -nostdlib --fatal-warnings -N -T vmxassist.tmp $(OBJECTS) 48.26 + $(LD) -o vmxassist $(LDFLAGS_DIRECT) -nostdlib --fatal-warnings -N -T vmxassist.tmp $(OBJECTS) 48.27 nm -n vmxassist > vmxassist.sym 48.28 $(OBJCOPY) vmxassist vmxassist.tmp 48.29 dd if=vmxassist.tmp of=vmxassist.bin ibs=512 conv=sync
49.1 --- a/tools/firmware/vmxassist/head.S Sun Oct 22 14:39:15 2006 -0600 49.2 +++ b/tools/firmware/vmxassist/head.S Sun Oct 22 15:23:52 2006 -0600 49.3 @@ -59,7 +59,7 @@ 49.4 49.5 /* go to protected mode */ 49.6 movl %cr0, %eax 49.7 - orl $CR0_PE, %eax 49.8 + orl $(CR0_PE), %eax 49.9 movl %eax, %cr0 49.10 data32 ljmp $0x08, $1f 49.11
50.1 --- a/tools/firmware/vmxassist/trap.S Sun Oct 22 14:39:15 2006 -0600 50.2 +++ b/tools/firmware/vmxassist/trap.S Sun Oct 22 15:23:52 2006 -0600 50.3 @@ -106,7 +106,7 @@ common_trap: /* common trap handler * 50.4 pushl %es 50.5 pushal 50.6 50.7 - movl $DATA_SELECTOR, %eax /* make sure these are sane */ 50.8 + movl $(DATA_SELECTOR), %eax /* make sure these are sane */ 50.9 movl %eax, %ds 50.10 movl %eax, %es 50.11 movl %eax, %fs
51.1 --- a/tools/firmware/vmxassist/util.c Sun Oct 22 14:39:15 2006 -0600 51.2 +++ b/tools/firmware/vmxassist/util.c Sun Oct 22 15:23:52 2006 -0600 51.3 @@ -29,6 +29,31 @@ static void putchar(int); 51.4 static char *printnum(char *, unsigned long, int); 51.5 static void _doprint(void (*)(int), char const *, va_list); 51.6 51.7 +void 51.8 +cpuid_addr_value(uint64_t addr, uint64_t *value) 51.9 +{ 51.10 + uint32_t addr_low = (uint32_t)addr; 51.11 + uint32_t addr_high = (uint32_t)(addr >> 32); 51.12 + uint32_t value_low, value_high; 51.13 + static unsigned int addr_leaf; 51.14 + 51.15 + if (!addr_leaf) { 51.16 + unsigned int eax, ebx, ecx, edx; 51.17 + __asm__ __volatile__( 51.18 + "cpuid" 51.19 + : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) 51.20 + : "0" (0x40000000)); 51.21 + addr_leaf = eax + 1; 51.22 + } 51.23 + 51.24 + __asm__ __volatile__( 51.25 + "cpuid" 51.26 + : "=c" (value_low), "=d" (value_high) 51.27 + : "a" (addr_leaf), "0" (addr_low), "1" (addr_high) 51.28 + : "ebx"); 51.29 + 51.30 + *value = (uint64_t)value_high << 32 | value_low; 51.31 +} 51.32 51.33 void 51.34 dump_regs(struct regs *regs)
52.1 --- a/tools/firmware/vmxassist/util.h Sun Oct 22 14:39:15 2006 -0600 52.2 +++ b/tools/firmware/vmxassist/util.h Sun Oct 22 15:23:52 2006 -0600 52.3 @@ -31,6 +31,7 @@ 52.4 52.5 struct vmx_assist_context; 52.6 52.7 +extern void cpuid_addr_value(uint64_t addr, uint64_t *value); 52.8 extern void hexdump(unsigned char *, int); 52.9 extern void dump_regs(struct regs *); 52.10 extern void dump_vmx_context(struct vmx_assist_context *);
53.1 --- a/tools/firmware/vmxassist/vm86.c Sun Oct 22 14:39:15 2006 -0600 53.2 +++ b/tools/firmware/vmxassist/vm86.c Sun Oct 22 15:23:52 2006 -0600 53.3 @@ -56,8 +56,8 @@ static char *rnames[] = { "ax", "cx", "d 53.4 #define PT_ENTRY_PRESENT 0x1 53.5 53.6 /* We only support access to <=4G physical memory due to 1:1 mapping */ 53.7 -static unsigned 53.8 -guest_linear_to_real(uint32_t base) 53.9 +static uint64_t 53.10 +guest_linear_to_phys(uint32_t base) 53.11 { 53.12 uint32_t gcr3 = oldctx.cr3; 53.13 uint64_t l2_mfn; 53.14 @@ -89,23 +89,32 @@ guest_linear_to_real(uint32_t base) 53.15 l2_mfn = ((uint64_t *)(long)gcr3)[(base >> 30) & 0x3]; 53.16 if (!(l2_mfn & PT_ENTRY_PRESENT)) 53.17 panic("l3 entry not present\n"); 53.18 - l2_mfn &= 0x3fffff000ULL; 53.19 + l2_mfn &= 0xffffff000ULL; 53.20 53.21 - l1_mfn = ((uint64_t *)(long)l2_mfn)[(base >> 21) & 0x1ff]; 53.22 + if (l2_mfn & 0xf00000000ULL) { 53.23 + printf("l2 page above 4G\n"); 53.24 + cpuid_addr_value(l2_mfn + 8 * ((base >> 21) & 0x1ff), &l1_mfn); 53.25 + } else 53.26 + l1_mfn = ((uint64_t *)(long)l2_mfn)[(base >> 21) & 0x1ff]; 53.27 if (!(l1_mfn & PT_ENTRY_PRESENT)) 53.28 panic("l2 entry not present\n"); 53.29 53.30 if (l1_mfn & PDE_PS) { /* CR4.PSE is ignored in PAE mode */ 53.31 - l0_mfn = l1_mfn & 0x3ffe00000ULL; 53.32 + l0_mfn = l1_mfn & 0xfffe00000ULL; 53.33 return l0_mfn + (base & 0x1fffff); 53.34 } 53.35 53.36 - l1_mfn &= 0x3fffff000ULL; 53.37 + l1_mfn &= 0xffffff000ULL; 53.38 53.39 - l0_mfn = ((uint64_t *)(long)l1_mfn)[(base >> 12) & 0x1ff]; 53.40 + if (l1_mfn & 0xf00000000ULL) { 53.41 + printf("l1 page above 4G\n"); 53.42 + cpuid_addr_value(l1_mfn + 8 * ((base >> 12) & 0x1ff), &l0_mfn); 53.43 + } else 53.44 + l0_mfn = ((uint64_t *)(long)l1_mfn)[(base >> 12) & 0x1ff]; 53.45 if (!(l0_mfn & PT_ENTRY_PRESENT)) 53.46 panic("l1 entry not present\n"); 53.47 - l0_mfn &= 0x3fffff000ULL; 53.48 + 53.49 + l0_mfn &= 0xffffff000ULL; 53.50 53.51 return l0_mfn + (base & 0xfff); 53.52 } 53.53 @@ -114,6 +123,7 @@ guest_linear_to_real(uint32_t base) 53.54 static unsigned 53.55 address(struct regs *regs, unsigned seg, unsigned off) 53.56 { 53.57 + uint64_t gdt_phys_base; 53.58 unsigned long long entry; 53.59 unsigned seg_base, seg_limit; 53.60 unsigned entry_low, entry_high; 53.61 @@ -129,8 +139,13 @@ address(struct regs *regs, unsigned seg, 53.62 (mode == VM86_REAL_TO_PROTECTED && regs->cs == seg)) 53.63 return ((seg & 0xFFFF) << 4) + off; 53.64 53.65 - entry = ((unsigned long long *) 53.66 - guest_linear_to_real(oldctx.gdtr_base))[seg >> 3]; 53.67 + gdt_phys_base = guest_linear_to_phys(oldctx.gdtr_base); 53.68 + if (gdt_phys_base != (uint32_t)gdt_phys_base) { 53.69 + printf("gdt base address above 4G\n"); 53.70 + cpuid_addr_value(gdt_phys_base + 8 * (seg >> 3), &entry); 53.71 + } else 53.72 + entry = ((unsigned long long *)(long)gdt_phys_base)[seg >> 3]; 53.73 + 53.74 entry_high = entry >> 32; 53.75 entry_low = entry & 0xFFFFFFFF; 53.76 53.77 @@ -804,6 +819,7 @@ pop(struct regs *regs, unsigned prefix, 53.78 static int 53.79 load_seg(unsigned long sel, uint32_t *base, uint32_t *limit, union vmcs_arbytes *arbytes) 53.80 { 53.81 + uint64_t gdt_phys_base; 53.82 unsigned long long entry; 53.83 53.84 /* protected mode: use seg as index into gdt */ 53.85 @@ -815,8 +831,12 @@ load_seg(unsigned long sel, uint32_t *ba 53.86 return 1; 53.87 } 53.88 53.89 - entry = ((unsigned long long *) 53.90 - guest_linear_to_real(oldctx.gdtr_base))[sel >> 3]; 53.91 + gdt_phys_base = guest_linear_to_phys(oldctx.gdtr_base); 53.92 + if (gdt_phys_base != (uint32_t)gdt_phys_base) { 53.93 + printf("gdt base address above 4G\n"); 53.94 + cpuid_addr_value(gdt_phys_base + 8 * (sel >> 3), &entry); 53.95 + } else 53.96 + entry = ((unsigned long long *)(long)gdt_phys_base)[sel >> 3]; 53.97 53.98 /* Check the P bit first */ 53.99 if (!((entry >> (15+32)) & 0x1) && sel != 0)
54.1 --- a/tools/guest-headers/Makefile Sun Oct 22 14:39:15 2006 -0600 54.2 +++ b/tools/guest-headers/Makefile Sun Oct 22 15:23:52 2006 -0600 54.3 @@ -1,5 +1,6 @@ 54.4 +XEN_ROOT=../.. 54.5 +include $(XEN_ROOT)/tools/Rules.mk 54.6 54.7 -XEN_ROOT=../.. 54.8 linuxsparsetree = $(XEN_ROOT)/linux-2.6-xen-sparse 54.9 54.10 .PHONY: all 54.11 @@ -8,10 +9,15 @@ all: 54.12 .PHONY: check 54.13 check: 54.14 54.15 -.PHONY: install 54.16 -install: 54.17 +.PHONY: install install-Linux install-SunOS 54.18 + 54.19 +install-Linux: 54.20 mkdir -p $(DESTDIR)/usr/include/xen/linux 54.21 install -m0644 $(linuxsparsetree)/include/xen/public/*.h $(DESTDIR)/usr/include/xen/linux 54.22 54.23 +install-SunOS: 54.24 + 54.25 +install: install-$(XEN_OS) 54.26 + 54.27 .PHONY: clean 54.28 clean:
55.1 --- a/tools/ioemu/Makefile.target Sun Oct 22 14:39:15 2006 -0600 55.2 +++ b/tools/ioemu/Makefile.target Sun Oct 22 15:23:52 2006 -0600 55.3 @@ -23,7 +23,7 @@ VPATH+=:$(SRC_PATH)/linux-user 55.4 DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH) 55.5 endif 55.6 CFLAGS+=-Wall -O2 -g -fno-strict-aliasing 55.7 -SSE2 := $(call test-gcc-flag,$(CC),-msse2) 55.8 +SSE2 := $(call cc-option,$(CC),-msse2,) 55.9 ifeq ($(SSE2),-msse2) 55.10 CFLAGS += -DUSE_SSE2=1 -msse2 55.11 endif 55.12 @@ -294,7 +294,11 @@ OBJS+=gdbstub.o 55.13 endif 55.14 55.15 # qemu-dm objects 55.16 +ifeq ($(ARCH),ia64) 55.17 LIBOBJS=helper2.o exec-dm.o i8259-dm.o 55.18 +else 55.19 +LIBOBJS=helper2.o exec-dm.o i8259-dm.o rtc-dm.o 55.20 +endif 55.21 55.22 all: $(PROGS) 55.23 55.24 @@ -354,7 +358,11 @@ VL_OBJS+= ne2000.o rtl8139.o pcnet.o 55.25 ifeq ($(TARGET_BASE_ARCH), i386) 55.26 # Hardware support 55.27 VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV) 55.28 +ifeq ($(ARCH),ia64) 55.29 VL_OBJS+= fdc.o mc146818rtc.o serial.o pc.o 55.30 +else 55.31 +VL_OBJS+= fdc.o serial.o pc.o 55.32 +endif 55.33 VL_OBJS+= cirrus_vga.o mixeng.o parallel.o acpi.o piix_pci.o 55.34 VL_OBJS+= usb-uhci.o 55.35 VL_OBJS+= piix4acpi.o 55.36 @@ -398,6 +406,7 @@ ifdef CONFIG_SDL 55.37 VL_OBJS+=sdl.o 55.38 endif 55.39 VL_OBJS+=vnc.o 55.40 +VL_OBJS+=d3des.o 55.41 ifdef CONFIG_COCOA 55.42 VL_OBJS+=cocoa.o 55.43 COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa -framework IOKit 55.44 @@ -458,6 +467,9 @@ sdl.o: sdl.c keymaps.c sdl_keysym.h 55.45 vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h 55.46 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $< 55.47 55.48 +d3des.o: d3des.c d3des.h 55.49 + $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $< 55.50 + 55.51 sdlaudio.o: sdlaudio.c 55.52 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $< 55.53 55.54 @@ -555,10 +567,10 @@ distclean: clean 55.55 install: all 55.56 mkdir -p "$(DESTDIR)$(bindir)" "$(DESTDIR)$(configdir)" 55.57 ifneq ($(PROGS),) 55.58 - $(INSTALL) -m 755 -s $(PROGS) "$(DESTDIR)$(bindir)" 55.59 + $(INSTALL_PROG) $(PROGS) "$(DESTDIR)$(bindir)" 55.60 endif 55.61 - install -m 755 $(TARGET_PATH)/qemu-dm.debug "$(DESTDIR)$(bindir)" 55.62 - install -m 755 $(TARGET_PATH)/qemu-ifup "$(DESTDIR)$(configdir)" 55.63 + $(INSTALL_PROG) $(TARGET_PATH)/qemu-dm.debug "$(DESTDIR)$(bindir)" 55.64 + $(INSTALL_PROG) $(TARGET_PATH)/qemu-ifup "$(DESTDIR)$(configdir)" 55.65 55.66 ifneq ($(wildcard .depend),) 55.67 include .depend
56.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 56.2 +++ b/tools/ioemu/d3des.c Sun Oct 22 15:23:52 2006 -0600 56.3 @@ -0,0 +1,434 @@ 56.4 +/* 56.5 + * This is D3DES (V5.09) by Richard Outerbridge with the double and 56.6 + * triple-length support removed for use in VNC. Also the bytebit[] array 56.7 + * has been reversed so that the most significant bit in each byte of the 56.8 + * key is ignored, not the least significant. 56.9 + * 56.10 + * These changes are: 56.11 + * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. 56.12 + * 56.13 + * This software is distributed in the hope that it will be useful, 56.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 56.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 56.16 + */ 56.17 + 56.18 +/* D3DES (V5.09) - 56.19 + * 56.20 + * A portable, public domain, version of the Data Encryption Standard. 56.21 + * 56.22 + * Written with Symantec's THINK (Lightspeed) C by Richard Outerbridge. 56.23 + * Thanks to: Dan Hoey for his excellent Initial and Inverse permutation 56.24 + * code; Jim Gillogly & Phil Karn for the DES key schedule code; Dennis 56.25 + * Ferguson, Eric Young and Dana How for comparing notes; and Ray Lau, 56.26 + * for humouring me on. 56.27 + * 56.28 + * Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge. 56.29 + * (GEnie : OUTER; CIS : [71755,204]) Graven Imagery, 1992. 56.30 + */ 56.31 + 56.32 +#include "d3des.h" 56.33 + 56.34 +static void scrunch(unsigned char *, unsigned long *); 56.35 +static void unscrun(unsigned long *, unsigned char *); 56.36 +static void desfunc(unsigned long *, unsigned long *); 56.37 +static void cookey(unsigned long *); 56.38 + 56.39 +static unsigned long KnL[32] = { 0L }; 56.40 + 56.41 +static unsigned short bytebit[8] = { 56.42 + 01, 02, 04, 010, 020, 040, 0100, 0200 }; 56.43 + 56.44 +static unsigned long bigbyte[24] = { 56.45 + 0x800000L, 0x400000L, 0x200000L, 0x100000L, 56.46 + 0x80000L, 0x40000L, 0x20000L, 0x10000L, 56.47 + 0x8000L, 0x4000L, 0x2000L, 0x1000L, 56.48 + 0x800L, 0x400L, 0x200L, 0x100L, 56.49 + 0x80L, 0x40L, 0x20L, 0x10L, 56.50 + 0x8L, 0x4L, 0x2L, 0x1L }; 56.51 + 56.52 +/* Use the key schedule specified in the Standard (ANSI X3.92-1981). */ 56.53 + 56.54 +static unsigned char pc1[56] = { 56.55 + 56, 48, 40, 32, 24, 16, 8, 0, 57, 49, 41, 33, 25, 17, 56.56 + 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 56.57 + 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 56.58 + 13, 5, 60, 52, 44, 36, 28, 20, 12, 4, 27, 19, 11, 3 }; 56.59 + 56.60 +static unsigned char totrot[16] = { 56.61 + 1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28 }; 56.62 + 56.63 +static unsigned char pc2[48] = { 56.64 + 13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9, 56.65 + 22, 18, 11, 3, 25, 7, 15, 6, 26, 19, 12, 1, 56.66 + 40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47, 56.67 + 43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31 }; 56.68 + 56.69 +void deskey(key, edf) /* Thanks to James Gillogly & Phil Karn! */ 56.70 +unsigned char *key; 56.71 +int edf; 56.72 +{ 56.73 + register int i, j, l, m, n; 56.74 + unsigned char pc1m[56], pcr[56]; 56.75 + unsigned long kn[32]; 56.76 + 56.77 + for ( j = 0; j < 56; j++ ) { 56.78 + l = pc1[j]; 56.79 + m = l & 07; 56.80 + pc1m[j] = (key[l >> 3] & bytebit[m]) ? 1 : 0; 56.81 + } 56.82 + for( i = 0; i < 16; i++ ) { 56.83 + if( edf == DE1 ) m = (15 - i) << 1; 56.84 + else m = i << 1; 56.85 + n = m + 1; 56.86 + kn[m] = kn[n] = 0L; 56.87 + for( j = 0; j < 28; j++ ) { 56.88 + l = j + totrot[i]; 56.89 + if( l < 28 ) pcr[j] = pc1m[l]; 56.90 + else pcr[j] = pc1m[l - 28]; 56.91 + } 56.92 + for( j = 28; j < 56; j++ ) { 56.93 + l = j + totrot[i]; 56.94 + if( l < 56 ) pcr[j] = pc1m[l]; 56.95 + else pcr[j] = pc1m[l - 28]; 56.96 + } 56.97 + for( j = 0; j < 24; j++ ) { 56.98 + if( pcr[pc2[j]] ) kn[m] |= bigbyte[j]; 56.99 + if( pcr[pc2[j+24]] ) kn[n] |= bigbyte[j]; 56.100 + } 56.101 + } 56.102 + cookey(kn); 56.103 + return; 56.104 + } 56.105 + 56.106 +static void cookey(raw1) 56.107 +register unsigned long *raw1; 56.108 +{ 56.109 + register unsigned long *cook, *raw0; 56.110 + unsigned long dough[32]; 56.111 + register int i; 56.112 + 56.113 + cook = dough; 56.114 + for( i = 0; i < 16; i++, raw1++ ) { 56.115 + raw0 = raw1++; 56.116 + *cook = (*raw0 & 0x00fc0000L) << 6; 56.117 + *cook |= (*raw0 & 0x00000fc0L) << 10; 56.118 + *cook |= (*raw1 & 0x00fc0000L) >> 10; 56.119 + *cook++ |= (*raw1 & 0x00000fc0L) >> 6; 56.120 + *cook = (*raw0 & 0x0003f000L) << 12; 56.121 + *cook |= (*raw0 & 0x0000003fL) << 16; 56.122 + *cook |= (*raw1 & 0x0003f000L) >> 4; 56.123 + *cook++ |= (*raw1 & 0x0000003fL); 56.124 + } 56.125 + usekey(dough); 56.126 + return; 56.127 + } 56.128 + 56.129 +void cpkey(into) 56.130 +register unsigned long *into; 56.131 +{ 56.132 + register unsigned long *from, *endp; 56.133 + 56.134 + from = KnL, endp = &KnL[32]; 56.135 + while( from < endp ) *into++ = *from++; 56.136 + return; 56.137 + } 56.138 + 56.139 +void usekey(from) 56.140 +register unsigned long *from; 56.141 +{ 56.142 + register unsigned long *to, *endp; 56.143 + 56.144 + to = KnL, endp = &KnL[32]; 56.145 + while( to < endp ) *to++ = *from++; 56.146 + return; 56.147 + } 56.148 + 56.149 +void des(inblock, outblock) 56.150 +unsigned char *inblock, *outblock; 56.151 +{ 56.152 + unsigned long work[2]; 56.153 + 56.154 + scrunch(inblock, work); 56.155 + desfunc(work, KnL); 56.156 + unscrun(work, outblock); 56.157 + return; 56.158 + } 56.159 + 56.160 +static void scrunch(outof, into) 56.161 +register unsigned char *outof; 56.162 +register unsigned long *into; 56.163 +{ 56.164 + *into = (*outof++ & 0xffL) << 24; 56.165 + *into |= (*outof++ & 0xffL) << 16; 56.166 + *into |= (*outof++ & 0xffL) << 8; 56.167 + *into++ |= (*outof++ & 0xffL); 56.168 + *into = (*outof++ & 0xffL) << 24; 56.169 + *into |= (*outof++ & 0xffL) << 16; 56.170 + *into |= (*outof++ & 0xffL) << 8; 56.171 + *into |= (*outof & 0xffL); 56.172 + return; 56.173 + } 56.174 + 56.175 +static void unscrun(outof, into) 56.176 +register unsigned long *outof; 56.177 +register unsigned char *into; 56.178 +{ 56.179 + *into++ = (unsigned char)((*outof >> 24) & 0xffL); 56.180 + *into++ = (unsigned char)((*outof >> 16) & 0xffL); 56.181 + *into++ = (unsigned char)((*outof >> 8) & 0xffL); 56.182 + *into++ = (unsigned char)(*outof++ & 0xffL); 56.183 + *into++ = (unsigned char)((*outof >> 24) & 0xffL); 56.184 + *into++ = (unsigned char)((*outof >> 16) & 0xffL); 56.185 + *into++ = (unsigned char)((*outof >> 8) & 0xffL); 56.186 + *into = (unsigned char)(*outof & 0xffL); 56.187 + return; 56.188 + } 56.189 + 56.190 +static unsigned long SP1[64] = { 56.191 + 0x01010400L, 0x00000000L, 0x00010000L, 0x01010404L, 56.192 + 0x01010004L, 0x00010404L, 0x00000004L, 0x00010000L, 56.193 + 0x00000400L, 0x01010400L, 0x01010404L, 0x00000400L, 56.194 + 0x01000404L, 0x01010004L, 0x01000000L, 0x00000004L, 56.195 + 0x00000404L, 0x01000400L, 0x01000400L, 0x00010400L, 56.196 + 0x00010400L, 0x01010000L, 0x01010000L, 0x01000404L, 56.197 + 0x00010004L, 0x01000004L, 0x01000004L, 0x00010004L, 56.198 + 0x00000000L, 0x00000404L, 0x00010404L, 0x01000000L, 56.199 + 0x00010000L, 0x01010404L, 0x00000004L, 0x01010000L, 56.200 + 0x01010400L, 0x01000000L, 0x01000000L, 0x00000400L, 56.201 + 0x01010004L, 0x00010000L, 0x00010400L, 0x01000004L, 56.202 + 0x00000400L, 0x00000004L, 0x01000404L, 0x00010404L, 56.203 + 0x01010404L, 0x00010004L, 0x01010000L, 0x01000404L, 56.204 + 0x01000004L, 0x00000404L, 0x00010404L, 0x01010400L, 56.205 + 0x00000404L, 0x01000400L, 0x01000400L, 0x00000000L, 56.206 + 0x00010004L, 0x00010400L, 0x00000000L, 0x01010004L }; 56.207 + 56.208 +static unsigned long SP2[64] = { 56.209 + 0x80108020L, 0x80008000L, 0x00008000L, 0x00108020L, 56.210 + 0x00100000L, 0x00000020L, 0x80100020L, 0x80008020L, 56.211 + 0x80000020L, 0x80108020L, 0x80108000L, 0x80000000L, 56.212 + 0x80008000L, 0x00100000L, 0x00000020L, 0x80100020L, 56.213 + 0x00108000L, 0x00100020L, 0x80008020L, 0x00000000L, 56.214 + 0x80000000L, 0x00008000L, 0x00108020L, 0x80100000L, 56.215 + 0x00100020L, 0x80000020L, 0x00000000L, 0x00108000L, 56.216 + 0x00008020L, 0x80108000L, 0x80100000L, 0x00008020L, 56.217 + 0x00000000L, 0x00108020L, 0x80100020L, 0x00100000L, 56.218 + 0x80008020L, 0x80100000L, 0x80108000L, 0x00008000L, 56.219 + 0x80100000L, 0x80008000L, 0x00000020L, 0x80108020L, 56.220 + 0x00108020L, 0x00000020L, 0x00008000L, 0x80000000L, 56.221 + 0x00008020L, 0x80108000L, 0x00100000L, 0x80000020L, 56.222 + 0x00100020L, 0x80008020L, 0x80000020L, 0x00100020L, 56.223 + 0x00108000L, 0x00000000L, 0x80008000L, 0x00008020L, 56.224 + 0x80000000L, 0x80100020L, 0x80108020L, 0x00108000L }; 56.225 + 56.226 +static unsigned long SP3[64] = { 56.227 + 0x00000208L, 0x08020200L, 0x00000000L, 0x08020008L, 56.228 + 0x08000200L, 0x00000000L, 0x00020208L, 0x08000200L, 56.229 + 0x00020008L, 0x08000008L, 0x08000008L, 0x00020000L, 56.230 + 0x08020208L, 0x00020008L, 0x08020000L, 0x00000208L, 56.231 + 0x08000000L, 0x00000008L, 0x08020200L, 0x00000200L, 56.232 + 0x00020200L, 0x08020000L, 0x08020008L, 0x00020208L, 56.233 + 0x08000208L, 0x00020200L, 0x00020000L, 0x08000208L, 56.234 + 0x00000008L, 0x08020208L, 0x00000200L, 0x08000000L, 56.235 + 0x08020200L, 0x08000000L, 0x00020008L, 0x00000208L, 56.236 + 0x00020000L, 0x08020200L, 0x08000200L, 0x00000000L, 56.237 + 0x00000200L, 0x00020008L, 0x08020208L, 0x08000200L, 56.238 + 0x08000008L, 0x00000200L, 0x00000000L, 0x08020008L, 56.239 + 0x08000208L, 0x00020000L, 0x08000000L, 0x08020208L, 56.240 + 0x00000008L, 0x00020208L, 0x00020200L, 0x08000008L, 56.241 + 0x08020000L, 0x08000208L, 0x00000208L, 0x08020000L, 56.242 + 0x00020208L, 0x00000008L, 0x08020008L, 0x00020200L }; 56.243 + 56.244 +static unsigned long SP4[64] = { 56.245 + 0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L, 56.246 + 0x00802080L, 0x00800081L, 0x00800001L, 0x00002001L, 56.247 + 0x00000000L, 0x00802000L, 0x00802000L, 0x00802081L, 56.248 + 0x00000081L, 0x00000000L, 0x00800080L, 0x00800001L, 56.249 + 0x00000001L, 0x00002000L, 0x00800000L, 0x00802001L, 56.250 + 0x00000080L, 0x00800000L, 0x00002001L, 0x00002080L, 56.251 + 0x00800081L, 0x00000001L, 0x00002080L, 0x00800080L, 56.252 + 0x00002000L, 0x00802080L, 0x00802081L, 0x00000081L, 56.253 + 0x00800080L, 0x00800001L, 0x00802000L, 0x00802081L, 56.254 + 0x00000081L, 0x00000000L, 0x00000000L, 0x00802000L, 56.255 + 0x00002080L, 0x00800080L, 0x00800081L, 0x00000001L, 56.256 + 0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L, 56.257 + 0x00802081L, 0x00000081L, 0x00000001L, 0x00002000L, 56.258 + 0x00800001L, 0x00002001L, 0x00802080L, 0x00800081L, 56.259 + 0x00002001L, 0x00002080L, 0x00800000L, 0x00802001L, 56.260 + 0x00000080L, 0x00800000L, 0x00002000L, 0x00802080L }; 56.261 + 56.262 +static unsigned long SP5[64] = { 56.263 + 0x00000100L, 0x02080100L, 0x02080000L, 0x42000100L, 56.264 + 0x00080000L, 0x00000100L, 0x40000000L, 0x02080000L, 56.265 + 0x40080100L, 0x00080000L, 0x02000100L, 0x40080100L, 56.266 + 0x42000100L, 0x42080000L, 0x00080100L, 0x40000000L, 56.267 + 0x02000000L, 0x40080000L, 0x40080000L, 0x00000000L, 56.268 + 0x40000100L, 0x42080100L, 0x42080100L, 0x02000100L, 56.269 + 0x42080000L, 0x40000100L, 0x00000000L, 0x42000000L, 56.270 + 0x02080100L, 0x02000000L, 0x42000000L, 0x00080100L, 56.271 + 0x00080000L, 0x42000100L, 0x00000100L, 0x02000000L, 56.272 + 0x40000000L, 0x02080000L, 0x42000100L, 0x40080100L, 56.273 + 0x02000100L, 0x40000000L, 0x42080000L, 0x02080100L, 56.274 + 0x40080100L, 0x00000100L, 0x02000000L, 0x42080000L, 56.275 + 0x42080100L, 0x00080100L, 0x42000000L, 0x42080100L, 56.276 + 0x02080000L, 0x00000000L, 0x40080000L, 0x42000000L, 56.277 + 0x00080100L, 0x02000100L, 0x40000100L, 0x00080000L, 56.278 + 0x00000000L, 0x40080000L, 0x02080100L, 0x40000100L }; 56.279 + 56.280 +static unsigned long SP6[64] = { 56.281 + 0x20000010L, 0x20400000L, 0x00004000L, 0x20404010L, 56.282 + 0x20400000L, 0x00000010L, 0x20404010L, 0x00400000L, 56.283 + 0x20004000L, 0x00404010L, 0x00400000L, 0x20000010L, 56.284 + 0x00400010L, 0x20004000L, 0x20000000L, 0x00004010L, 56.285 + 0x00000000L, 0x00400010L, 0x20004010L, 0x00004000L, 56.286 + 0x00404000L, 0x20004010L, 0x00000010L, 0x20400010L, 56.287 + 0x20400010L, 0x00000000L, 0x00404010L, 0x20404000L, 56.288 + 0x00004010L, 0x00404000L, 0x20404000L, 0x20000000L, 56.289 + 0x20004000L, 0x00000010L, 0x20400010L, 0x00404000L, 56.290 + 0x20404010L, 0x00400000L, 0x00004010L, 0x20000010L, 56.291 + 0x00400000L, 0x20004000L, 0x20000000L, 0x00004010L, 56.292 + 0x20000010L, 0x20404010L, 0x00404000L, 0x20400000L, 56.293 + 0x00404010L, 0x20404000L, 0x00000000L, 0x20400010L, 56.294 + 0x00000010L, 0x00004000L, 0x20400000L, 0x00404010L, 56.295 + 0x00004000L, 0x00400010L, 0x20004010L, 0x00000000L, 56.296 + 0x20404000L, 0x20000000L, 0x00400010L, 0x20004010L }; 56.297 + 56.298 +static unsigned long SP7[64] = { 56.299 + 0x00200000L, 0x04200002L, 0x04000802L, 0x00000000L, 56.300 + 0x00000800L, 0x04000802L, 0x00200802L, 0x04200800L, 56.301 + 0x04200802L, 0x00200000L, 0x00000000L, 0x04000002L, 56.302 + 0x00000002L, 0x04000000L, 0x04200002L, 0x00000802L, 56.303 + 0x04000800L, 0x00200802L, 0x00200002L, 0x04000800L, 56.304 + 0x04000002L, 0x04200000L, 0x04200800L, 0x00200002L, 56.305 + 0x04200000L, 0x00000800L, 0x00000802L, 0x04200802L, 56.306 + 0x00200800L, 0x00000002L, 0x04000000L, 0x00200800L, 56.307 + 0x04000000L, 0x00200800L, 0x00200000L, 0x04000802L, 56.308 + 0x04000802L, 0x04200002L, 0x04200002L, 0x00000002L, 56.309 + 0x00200002L, 0x04000000L, 0x04000800L, 0x00200000L, 56.310 + 0x04200800L, 0x00000802L, 0x00200802L, 0x04200800L, 56.311 + 0x00000802L, 0x04000002L, 0x04200802L, 0x04200000L, 56.312 + 0x00200800L, 0x00000000L, 0x00000002L, 0x04200802L, 56.313 + 0x00000000L, 0x00200802L, 0x04200000L, 0x00000800L, 56.314 + 0x04000002L, 0x04000800L, 0x00000800L, 0x00200002L }; 56.315 + 56.316 +static unsigned long SP8[64] = { 56.317 + 0x10001040L, 0x00001000L, 0x00040000L, 0x10041040L, 56.318 + 0x10000000L, 0x10001040L, 0x00000040L, 0x10000000L, 56.319 + 0x00040040L, 0x10040000L, 0x10041040L, 0x00041000L, 56.320 + 0x10041000L, 0x00041040L, 0x00001000L, 0x00000040L, 56.321 + 0x10040000L, 0x10000040L, 0x10001000L, 0x00001040L, 56.322 + 0x00041000L, 0x00040040L, 0x10040040L, 0x10041000L, 56.323 + 0x00001040L, 0x00000000L, 0x00000000L, 0x10040040L, 56.324 + 0x10000040L, 0x10001000L, 0x00041040L, 0x00040000L, 56.325 + 0x00041040L, 0x00040000L, 0x10041000L, 0x00001000L, 56.326 + 0x00000040L, 0x10040040L, 0x00001000L, 0x00041040L, 56.327 + 0x10001000L, 0x00000040L, 0x10000040L, 0x10040000L, 56.328 + 0x10040040L, 0x10000000L, 0x00040000L, 0x10001040L, 56.329 + 0x00000000L, 0x10041040L, 0x00040040L, 0x10000040L, 56.330 + 0x10040000L, 0x10001000L, 0x10001040L, 0x00000000L, 56.331 + 0x10041040L, 0x00041000L, 0x00041000L, 0x00001040L, 56.332 + 0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L }; 56.333 + 56.334 +static void desfunc(block, keys) 56.335 +register unsigned long *block, *keys; 56.336 +{ 56.337 + register unsigned long fval, work, right, leftt; 56.338 + register int round; 56.339 + 56.340 + leftt = block[0]; 56.341 + right = block[1]; 56.342 + work = ((leftt >> 4) ^ right) & 0x0f0f0f0fL; 56.343 + right ^= work; 56.344 + leftt ^= (work << 4); 56.345 + work = ((leftt >> 16) ^ right) & 0x0000ffffL; 56.346 + right ^= work; 56.347 + leftt ^= (work << 16); 56.348 + work = ((right >> 2) ^ leftt) & 0x33333333L; 56.349 + leftt ^= work; 56.350 + right ^= (work << 2); 56.351 + work = ((right >> 8) ^ leftt) & 0x00ff00ffL; 56.352 + leftt ^= work; 56.353 + right ^= (work << 8); 56.354 + right = ((right << 1) | ((right >> 31) & 1L)) & 0xffffffffL; 56.355 + work = (leftt ^ right) & 0xaaaaaaaaL; 56.356 + leftt ^= work; 56.357 + right ^= work; 56.358 + leftt = ((leftt << 1) | ((leftt >> 31) & 1L)) & 0xffffffffL; 56.359 + 56.360 + for( round = 0; round < 8; round++ ) { 56.361 + work = (right << 28) | (right >> 4); 56.362 + work ^= *keys++; 56.363 + fval = SP7[ work & 0x3fL]; 56.364 + fval |= SP5[(work >> 8) & 0x3fL]; 56.365 + fval |= SP3[(work >> 16) & 0x3fL]; 56.366 + fval |= SP1[(work >> 24) & 0x3fL]; 56.367 + work = right ^ *keys++; 56.368 + fval |= SP8[ work & 0x3fL]; 56.369 + fval |= SP6[(work >> 8) & 0x3fL]; 56.370 + fval |= SP4[(work >> 16) & 0x3fL]; 56.371 + fval |= SP2[(work >> 24) & 0x3fL]; 56.372 + leftt ^= fval; 56.373 + work = (leftt << 28) | (leftt >> 4); 56.374 + work ^= *keys++; 56.375 + fval = SP7[ work & 0x3fL]; 56.376 + fval |= SP5[(work >> 8) & 0x3fL]; 56.377 + fval |= SP3[(work >> 16) & 0x3fL]; 56.378 + fval |= SP1[(work >> 24) & 0x3fL]; 56.379 + work = leftt ^ *keys++; 56.380 + fval |= SP8[ work & 0x3fL]; 56.381 + fval |= SP6[(work >> 8) & 0x3fL]; 56.382 + fval |= SP4[(work >> 16) & 0x3fL]; 56.383 + fval |= SP2[(work >> 24) & 0x3fL]; 56.384 + right ^= fval; 56.385 + } 56.386 + 56.387 + right = (right << 31) | (right >> 1); 56.388 + work = (leftt ^ right) & 0xaaaaaaaaL; 56.389 + leftt ^= work; 56.390 + right ^= work; 56.391 + leftt = (leftt << 31) | (leftt >> 1); 56.392 + work = ((leftt >> 8) ^ right) & 0x00ff00ffL; 56.393 + right ^= work; 56.394 + leftt ^= (work << 8); 56.395 + work = ((leftt >> 2) ^ right) & 0x33333333L; 56.396 + right ^= work; 56.397 + leftt ^= (work << 2); 56.398 + work = ((right >> 16) ^ leftt) & 0x0000ffffL; 56.399 + leftt ^= work; 56.400 + right ^= (work << 16); 56.401 + work = ((right >> 4) ^ leftt) & 0x0f0f0f0fL; 56.402 + leftt ^= work; 56.403 + right ^= (work << 4); 56.404 + *block++ = right; 56.405 + *block = leftt; 56.406 + return; 56.407 + } 56.408 + 56.409 +/* Validation sets: 56.410 + * 56.411 + * Single-length key, single-length plaintext - 56.412 + * Key : 0123 4567 89ab cdef 56.413 + * Plain : 0123 4567 89ab cde7 56.414 + * Cipher : c957 4425 6a5e d31d 56.415 + * 56.416 + * Double-length key, single-length plaintext - 56.417 + * Key : 0123 4567 89ab cdef fedc ba98 7654 3210 56.418 + * Plain : 0123 4567 89ab cde7 56.419 + * Cipher : 7f1d 0a77 826b 8aff 56.420 + * 56.421 + * Double-length key, double-length plaintext - 56.422 + * Key : 0123 4567 89ab cdef fedc ba98 7654 3210 56.423 + * Plain : 0123 4567 89ab cdef 0123 4567 89ab cdff 56.424 + * Cipher : 27a0 8440 406a df60 278f 47cf 42d6 15d7 56.425 + * 56.426 + * Triple-length key, single-length plaintext - 56.427 + * Key : 0123 4567 89ab cdef fedc ba98 7654 3210 89ab cdef 0123 4567 56.428 + * Plain : 0123 4567 89ab cde7 56.429 + * Cipher : de0b 7c06 ae5e 0ed5 56.430 + * 56.431 + * Triple-length key, double-length plaintext - 56.432 + * Key : 0123 4567 89ab cdef fedc ba98 7654 3210 89ab cdef 0123 4567 56.433 + * Plain : 0123 4567 89ab cdef 0123 4567 89ab cdff 56.434 + * Cipher : ad0d 1b30 ac17 cf07 0ed1 1c63 81e4 4de5 56.435 + * 56.436 + * d3des V5.0a rwo 9208.07 18:44 Graven Imagery 56.437 + **********************************************************************/
57.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 57.2 +++ b/tools/ioemu/d3des.h Sun Oct 22 15:23:52 2006 -0600 57.3 @@ -0,0 +1,51 @@ 57.4 +/* 57.5 + * This is D3DES (V5.09) by Richard Outerbridge with the double and 57.6 + * triple-length support removed for use in VNC. 57.7 + * 57.8 + * These changes are: 57.9 + * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. 57.10 + * 57.11 + * This software is distributed in the hope that it will be useful, 57.12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 57.13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 57.14 + */ 57.15 + 57.16 +/* d3des.h - 57.17 + * 57.18 + * Headers and defines for d3des.c 57.19 + * Graven Imagery, 1992. 57.20 + * 57.21 + * Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge 57.22 + * (GEnie : OUTER; CIS : [71755,204]) 57.23 + */ 57.24 + 57.25 +#define EN0 0 /* MODE == encrypt */ 57.26 +#define DE1 1 /* MODE == decrypt */ 57.27 + 57.28 +extern void deskey(unsigned char *, int); 57.29 +/* hexkey[8] MODE 57.30 + * Sets the internal key register according to the hexadecimal 57.31 + * key contained in the 8 bytes of hexkey, according to the DES, 57.32 + * for encryption or decryption according to MODE. 57.33 + */ 57.34 + 57.35 +extern void usekey(unsigned long *); 57.36 +/* cookedkey[32] 57.37 + * Loads the internal key register with the data in cookedkey. 57.38 + */ 57.39 + 57.40 +extern void cpkey(unsigned long *); 57.41 +/* cookedkey[32] 57.42 + * Copies the contents of the internal key register into the storage 57.43 + * located at &cookedkey[0]. 57.44 + */ 57.45 + 57.46 +extern void des(unsigned char *, unsigned char *); 57.47 +/* from[8] to[8] 57.48 + * Encrypts/Decrypts (according to the key currently loaded in the 57.49 + * internal key register) one block of eight bytes at address 'from' 57.50 + * into the block at address 'to'. They can be the same. 57.51 + */ 57.52 + 57.53 +/* d3des.h V5.09 rwo 9208.04 15:06 Graven Imagery 57.54 + ********************************************************************/
58.1 --- a/tools/ioemu/hw/ide.c Sun Oct 22 14:39:15 2006 -0600 58.2 +++ b/tools/ioemu/hw/ide.c Sun Oct 22 15:23:52 2006 -0600 58.3 @@ -557,9 +557,9 @@ static void ide_atapi_identify(IDEState 58.4 padstr((uint8_t *)(p + 23), QEMU_VERSION, 8); /* firmware version */ 58.5 padstr((uint8_t *)(p + 27), "QEMU CD-ROM", 40); /* model */ 58.6 put_le16(p + 48, 1); /* dword I/O (XXX: should not be set on CDROM) */ 58.7 - put_le16(p + 49, 1 << 9); /* LBA supported, no DMA */ 58.8 + put_le16(p + 49, (1 << 11) | (1 << 9) | (1 << 8)); /* DMA and LBA supported */ 58.9 put_le16(p + 53, 3); /* words 64-70, 54-58 valid */ 58.10 - put_le16(p + 63, 0x103); /* DMA modes XXX: may be incorrect */ 58.11 + put_le16(p + 63, 0x07); /* mdma0-2 supported */ 58.12 put_le16(p + 64, 1); /* PIO modes */ 58.13 put_le16(p + 65, 0xb4); /* minimum DMA multiword tx cycle time */ 58.14 put_le16(p + 66, 0xb4); /* recommended DMA multiword tx cycle time */
59.1 --- a/tools/ioemu/hw/xen_platform.c Sun Oct 22 14:39:15 2006 -0600 59.2 +++ b/tools/ioemu/hw/xen_platform.c Sun Oct 22 15:23:52 2006 -0600 59.3 @@ -97,7 +97,8 @@ struct pci_config_header { 59.4 uint8_t bist; /* Built in self test */ 59.5 uint32_t base_address_regs[6]; 59.6 uint32_t reserved1; 59.7 - uint32_t reserved2; 59.8 + uint16_t subsystem_vendor_id; 59.9 + uint16_t subsystem_id; 59.10 uint32_t rom_addr; 59.11 uint32_t reserved3; 59.12 uint32_t reserved4; 59.13 @@ -126,6 +127,11 @@ void pci_xen_platform_init(PCIBus *bus) 59.14 pch->header_type = 0; 59.15 pch->interrupt_pin = 1; 59.16 59.17 + /* Microsoft WHQL requires non-zero subsystem IDs. */ 59.18 + /* http://www.pcisig.com/reflector/msg02205.html. */ 59.19 + pch->subsystem_vendor_id = pch->vendor_id; /* Duplicate vendor id. */ 59.20 + pch->subsystem_id = 0x0001; /* Hardcode sub-id as 1. */ 59.21 + 59.22 pci_register_io_region(d, 0, 0x100, PCI_ADDRESS_SPACE_IO, 59.23 platform_ioport_map); 59.24
60.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 60.2 +++ b/tools/ioemu/target-i386-dm/rtc-dm.c Sun Oct 22 15:23:52 2006 -0600 60.3 @@ -0,0 +1,107 @@ 60.4 +/* 60.5 + * QEMU MC146818 RTC emulation 60.6 + * 60.7 + * Copyright (c) 2003-2004 Fabrice Bellard 60.8 + * 60.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy 60.10 + * of this software and associated documentation files (the "Software"), to deal 60.11 + * in the Software without restriction, including without limitation the rights 60.12 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 60.13 + * copies of the Software, and to permit persons to whom the Software is 60.14 + * furnished to do so, subject to the following conditions: 60.15 + * 60.16 + * The above copyright notice and this permission notice shall be included in 60.17 + * all copies or substantial portions of the Software. 60.18 + * 60.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 60.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 60.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 60.22 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 60.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 60.24 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 60.25 + * THE SOFTWARE. 60.26 + */ 60.27 + 60.28 +#include "vl.h" 60.29 + 60.30 +//#define DEBUG_CMOS 60.31 + 60.32 +struct RTCState { 60.33 + uint8_t cmos_data[128]; 60.34 + uint8_t cmos_index; 60.35 +}; 60.36 + 60.37 +void rtc_set_memory(RTCState *s, int addr, int val) 60.38 +{ 60.39 + if (addr >= 0 && addr <= 127) 60.40 + s->cmos_data[addr] = val; 60.41 +} 60.42 + 60.43 +static void cmos_ioport_write(void *opaque, uint32_t addr, uint32_t data) 60.44 +{ 60.45 + RTCState *s = opaque; 60.46 + 60.47 + if ((addr & 1) == 0) { 60.48 + s->cmos_index = data & 0x7f; 60.49 + } else { 60.50 +#ifdef DEBUG_CMOS 60.51 + printf("cmos: write index=0x%02x val=0x%02x\n", 60.52 + s->cmos_index, data); 60.53 +#endif 60.54 + s->cmos_data[s->cmos_index] = data; 60.55 + } 60.56 +} 60.57 + 60.58 +static uint32_t cmos_ioport_read(void *opaque, uint32_t addr) 60.59 +{ 60.60 + RTCState *s = opaque; 60.61 + int ret; 60.62 + if ((addr & 1) == 0) { 60.63 + return 0xff; 60.64 + } else { 60.65 + ret = s->cmos_data[s->cmos_index]; 60.66 +#ifdef DEBUG_CMOS 60.67 + printf("cmos: read index=0x%02x val=0x%02x\n", 60.68 + s->cmos_index, ret); 60.69 +#endif 60.70 + return ret; 60.71 + } 60.72 +} 60.73 + 60.74 +static void rtc_save(QEMUFile *f, void *opaque) 60.75 +{ 60.76 + RTCState *s = opaque; 60.77 + 60.78 + qemu_put_buffer(f, s->cmos_data, 128); 60.79 + qemu_put_8s(f, &s->cmos_index); 60.80 +} 60.81 + 60.82 +static int rtc_load(QEMUFile *f, void *opaque, int version_id) 60.83 +{ 60.84 + RTCState *s = opaque; 60.85 + 60.86 + if (version_id != 1) 60.87 + return -EINVAL; 60.88 + 60.89 + qemu_get_buffer(f, s->cmos_data, 128); 60.90 + qemu_get_8s(f, &s->cmos_index); 60.91 + 60.92 + return 0; 60.93 +} 60.94 + 60.95 +RTCState *rtc_init(int base, int irq) 60.96 +{ 60.97 + RTCState *s; 60.98 + 60.99 + s = qemu_mallocz(sizeof(RTCState)); 60.100 + if (!s) 60.101 + return NULL; 60.102 + 60.103 + register_ioport_write(base, 2, 1, cmos_ioport_write, s); 60.104 + register_ioport_read(base, 2, 1, cmos_ioport_read, s); 60.105 + 60.106 + register_savevm("mc146818rtc", base, 1, rtc_save, rtc_load, s); 60.107 + return s; 60.108 +} 60.109 + 60.110 +void rtc_set_date(RTCState *s, const struct tm *tm) {}
61.1 --- a/tools/ioemu/vl.c Sun Oct 22 14:39:15 2006 -0600 61.2 +++ b/tools/ioemu/vl.c Sun Oct 22 15:23:52 2006 -0600 61.3 @@ -171,6 +171,9 @@ time_t timeoffset = 0; 61.4 char domain_name[1024] = { 'H','V', 'M', 'X', 'E', 'N', '-'}; 61.5 extern int domid; 61.6 61.7 +char vncpasswd[64]; 61.8 +unsigned char challenge[AUTHCHALLENGESIZE]; 61.9 + 61.10 /***********************************************************/ 61.11 /* x86 ISA bus support */ 61.12 61.13 @@ -3028,7 +3031,7 @@ void net_slirp_smb(const char *exported_ 61.14 } 61.15 61.16 /* XXX: better tmp dir construction */ 61.17 - snprintf(smb_dir, sizeof(smb_dir), "/tmp/qemu-smb.%d", getpid()); 61.18 + snprintf(smb_dir, sizeof(smb_dir), "/tmp/qemu-smb.%ld", (long)getpid()); 61.19 if (mkdir(smb_dir, 0700) < 0) { 61.20 fprintf(stderr, "qemu: could not create samba server dir '%s'\n", smb_dir); 61.21 exit(1); 61.22 @@ -3995,7 +3998,7 @@ static void create_pidfile(const char *f 61.23 perror("Opening pidfile"); 61.24 exit(1); 61.25 } 61.26 - fprintf(f, "%d\n", getpid()); 61.27 + fprintf(f, "%ld\n", (long)getpid()); 61.28 fclose(f); 61.29 pid_filename = qemu_strdup(filename); 61.30 if (!pid_filename) { 61.31 @@ -5911,6 +5914,7 @@ int main(int argc, char **argv) 61.32 vncunused = 0; 61.33 kernel_filename = NULL; 61.34 kernel_cmdline = ""; 61.35 + *vncpasswd = '\0'; 61.36 #ifndef CONFIG_DM 61.37 #ifdef TARGET_PPC 61.38 cdrom_index = 1; 61.39 @@ -5942,7 +5946,7 @@ int main(int argc, char **argv) 61.40 memset(&vnclisten_addr.sin_addr, 0, sizeof(vnclisten_addr.sin_addr)); 61.41 61.42 /* init debug */ 61.43 - sprintf(qemu_dm_logfilename, "/var/log/xen/qemu-dm.%d.log", getpid()); 61.44 + sprintf(qemu_dm_logfilename, "/var/log/xen/qemu-dm.%ld.log", (long)getpid()); 61.45 cpu_set_log_filename(qemu_dm_logfilename); 61.46 cpu_set_log(0); 61.47 61.48 @@ -6559,6 +6563,10 @@ int main(int argc, char **argv) 61.49 61.50 init_ioports(); 61.51 61.52 + /* read vncpasswd from xenstore */ 61.53 + if (0 > xenstore_read_vncpasswd(domid)) 61.54 + exit(1); 61.55 + 61.56 /* terminal init */ 61.57 if (nographic) { 61.58 dumb_display_init(ds);
62.1 --- a/tools/ioemu/vl.h Sun Oct 22 14:39:15 2006 -0600 62.2 +++ b/tools/ioemu/vl.h Sun Oct 22 15:23:52 2006 -0600 62.3 @@ -1211,6 +1211,7 @@ int xenstore_fd(void); 62.4 void xenstore_process_event(void *opaque); 62.5 void xenstore_check_new_media_present(int timeout); 62.6 void xenstore_write_vncport(int vnc_display); 62.7 +int xenstore_read_vncpasswd(int domid); 62.8 62.9 /* xen_platform.c */ 62.10 void pci_xen_platform_init(PCIBus *bus); 62.11 @@ -1222,4 +1223,7 @@ extern char domain_name[]; 62.12 62.13 void destroy_hvm_domain(void); 62.14 62.15 +/* VNC Authentication */ 62.16 +#define AUTHCHALLENGESIZE 16 62.17 + 62.18 #endif /* VL_H */
63.1 --- a/tools/ioemu/vnc.c Sun Oct 22 14:39:15 2006 -0600 63.2 +++ b/tools/ioemu/vnc.c Sun Oct 22 15:23:52 2006 -0600 63.3 @@ -44,6 +44,7 @@ 63.4 63.5 #include "vnc_keysym.h" 63.6 #include "keymaps.c" 63.7 +#include "d3des.h" 63.8 63.9 #define XK_MISCELLANY 63.10 #define XK_LATIN1 63.11 @@ -137,6 +138,9 @@ static void _vnc_update_client(void *opa 63.12 static void vnc_update_client(void *opaque); 63.13 static void vnc_client_read(void *opaque); 63.14 static void framebuffer_set_updated(VncState *vs, int x, int y, int w, int h); 63.15 +static int make_challenge(char *random, int size); 63.16 +static void set_seed(unsigned int *seedp); 63.17 +static void get_random(int len, unsigned char *buf); 63.18 63.19 #if 0 63.20 static inline void vnc_set_bit(uint32_t *d, int k) 63.21 @@ -1208,23 +1212,92 @@ static int protocol_client_init(VncState 63.22 return 0; 63.23 } 63.24 63.25 +static int protocol_response(VncState *vs, char *client_response, size_t len) 63.26 +{ 63.27 + extern char vncpasswd[64]; 63.28 + extern unsigned char challenge[AUTHCHALLENGESIZE]; 63.29 + unsigned char cryptchallenge[AUTHCHALLENGESIZE]; 63.30 + unsigned char key[8]; 63.31 + int passwdlen, i, j; 63.32 + 63.33 + memcpy(cryptchallenge, challenge, AUTHCHALLENGESIZE); 63.34 + 63.35 + /* Calculate the sent challenge */ 63.36 + passwdlen = strlen(vncpasswd); 63.37 + for (i=0; i<8; i++) 63.38 + key[i] = i<passwdlen ? vncpasswd[i] : 0; 63.39 + deskey(key, EN0); 63.40 + for (j = 0; j < AUTHCHALLENGESIZE; j += 8) 63.41 + des(cryptchallenge+j, cryptchallenge+j); 63.42 + 63.43 + /* Check the actual response */ 63.44 + if (memcmp(cryptchallenge, client_response, AUTHCHALLENGESIZE) != 0) { 63.45 + /* password error */ 63.46 + vnc_write_u32(vs, 1); 63.47 + vnc_write_u32(vs, 22); 63.48 + vnc_write(vs, "Authentication failure", 22); 63.49 + vnc_flush(vs); 63.50 + fprintf(stderr, "VNC Password error.\n"); 63.51 + vnc_client_error(vs); 63.52 + return 0; 63.53 + } 63.54 + 63.55 + vnc_write_u32(vs, 0); 63.56 + vnc_flush(vs); 63.57 + 63.58 + vnc_read_when(vs, protocol_client_init, 1); 63.59 + 63.60 + return 0; 63.61 +} 63.62 + 63.63 static int protocol_version(VncState *vs, char *version, size_t len) 63.64 { 63.65 + extern char vncpasswd[64]; 63.66 + extern unsigned char challenge[AUTHCHALLENGESIZE]; 63.67 char local[13]; 63.68 - int maj, min; 63.69 + int support, maj, min; 63.70 63.71 memcpy(local, version, 12); 63.72 local[12] = 0; 63.73 63.74 + /* protocol version check */ 63.75 if (sscanf(local, "RFB %03d.%03d\n", &maj, &min) != 2) { 63.76 + fprintf(stderr, "Protocol version error.\n"); 63.77 vnc_client_error(vs); 63.78 return 0; 63.79 } 63.80 63.81 - vnc_write_u32(vs, 1); /* None */ 63.82 - vnc_flush(vs); 63.83 + 63.84 + support = 0; 63.85 + if (maj = 3) { 63.86 + if (min == 3 || min ==4) { 63.87 + support = 1; 63.88 + } 63.89 + } 63.90 + 63.91 + if (! support) { 63.92 + fprintf(stderr, "Client uses unsupported protocol version %d.%d.\n", 63.93 + maj, min); 63.94 + vnc_client_error(vs); 63.95 + return 0; 63.96 + } 63.97 63.98 - vnc_read_when(vs, protocol_client_init, 1); 63.99 + if (*vncpasswd == '\0') { 63.100 + /* AuthType is None */ 63.101 + vnc_write_u32(vs, 1); 63.102 + vnc_flush(vs); 63.103 + vnc_read_when(vs, protocol_client_init, 1); 63.104 + } else { 63.105 + /* AuthType is VncAuth */ 63.106 + vnc_write_u32(vs, 2); 63.107 + 63.108 + /* Challenge-Responce authentication */ 63.109 + /* Send Challenge */ 63.110 + make_challenge(challenge, AUTHCHALLENGESIZE); 63.111 + vnc_write(vs, challenge, AUTHCHALLENGESIZE); 63.112 + vnc_flush(vs); 63.113 + vnc_read_when(vs, protocol_response, AUTHCHALLENGESIZE); 63.114 + } 63.115 63.116 return 0; 63.117 } 63.118 @@ -1342,3 +1415,32 @@ int vnc_start_viewer(int port) 63.119 return pid; 63.120 } 63.121 } 63.122 + 63.123 +unsigned int seed; 63.124 + 63.125 +static int make_challenge(char *random, int size) 63.126 +{ 63.127 + 63.128 + set_seed(&seed); 63.129 + get_random(size, random); 63.130 + 63.131 + return 0; 63.132 +} 63.133 + 63.134 +static void set_seed(unsigned int *seedp) 63.135 +{ 63.136 + *seedp += (unsigned int)(time(NULL)+getpid()+getpid()*987654+rand()); 63.137 + srand(*seedp); 63.138 + 63.139 + return; 63.140 +} 63.141 + 63.142 +static void get_random(int len, unsigned char *buf) 63.143 +{ 63.144 + int i; 63.145 + 63.146 + for (i=0; i<len; i++) 63.147 + buf[i] = (int) (256.0*rand()/(RAND_MAX+1.0)); 63.148 + 63.149 + return; 63.150 +}
64.1 --- a/tools/ioemu/xenstore.c Sun Oct 22 14:39:15 2006 -0600 64.2 +++ b/tools/ioemu/xenstore.c Sun Oct 22 15:23:52 2006 -0600 64.3 @@ -213,3 +213,54 @@ void xenstore_write_vncport(int display) 64.4 free(portstr); 64.5 free(buf); 64.6 } 64.7 + 64.8 +int xenstore_read_vncpasswd(int domid) 64.9 +{ 64.10 + extern char vncpasswd[64]; 64.11 + char *buf = NULL, *path, *uuid = NULL, *passwd = NULL; 64.12 + unsigned int i, len, rc = 0; 64.13 + 64.14 + if (xsh == NULL) { 64.15 + return -1; 64.16 + } 64.17 + 64.18 + path = xs_get_domain_path(xsh, domid); 64.19 + if (path == NULL) { 64.20 + fprintf(logfile, "xs_get_domain_path() error. domid %d.\n", domid); 64.21 + return -1; 64.22 + } 64.23 + 64.24 + pasprintf(&buf, "%s/vm", path); 64.25 + uuid = xs_read(xsh, XBT_NULL, buf, &len); 64.26 + if (uuid == NULL) { 64.27 + fprintf(logfile, "xs_read(): uuid get error. %s.\n", buf); 64.28 + free(path); 64.29 + return -1; 64.30 + } 64.31 + 64.32 + pasprintf(&buf, "%s/vncpasswd", uuid); 64.33 + passwd = xs_read(xsh, XBT_NULL, buf, &len); 64.34 + if (passwd == NULL) { 64.35 + fprintf(logfile, "xs_read(): vncpasswd get error. %s.\n", buf); 64.36 + free(uuid); 64.37 + free(path); 64.38 + return rc; 64.39 + } 64.40 + 64.41 + for (i=0; i<len && i<63; i++) { 64.42 + vncpasswd[i] = passwd[i]; 64.43 + passwd[i] = '\0'; 64.44 + } 64.45 + vncpasswd[len] = '\0'; 64.46 + pasprintf(&buf, "%s/vncpasswd", uuid); 64.47 + if (xs_write(xsh, XBT_NULL, buf, passwd, len) == 0) { 64.48 + fprintf(logfile, "xs_write() vncpasswd failed.\n"); 64.49 + rc = -1; 64.50 + } 64.51 + 64.52 + free(passwd); 64.53 + free(uuid); 64.54 + free(path); 64.55 + 64.56 + return rc; 64.57 +}
65.1 --- a/tools/libxc/Makefile Sun Oct 22 14:39:15 2006 -0600 65.2 +++ b/tools/libxc/Makefile Sun Oct 22 15:23:52 2006 -0600 65.3 @@ -1,15 +1,9 @@ 65.4 - 65.5 -INSTALL = install 65.6 -INSTALL_PROG = $(INSTALL) -m0755 65.7 -INSTALL_DATA = $(INSTALL) -m0644 65.8 -INSTALL_DIR = $(INSTALL) -d -m0755 65.9 +XEN_ROOT = ../.. 65.10 +include $(XEN_ROOT)/tools/Rules.mk 65.11 65.12 MAJOR = 3.0 65.13 MINOR = 0 65.14 65.15 -XEN_ROOT = ../.. 65.16 -include $(XEN_ROOT)/tools/Rules.mk 65.17 - 65.18 CTRL_SRCS-y := 65.19 CTRL_SRCS-y += xc_core.c 65.20 CTRL_SRCS-y += xc_domain.c 65.21 @@ -21,8 +15,10 @@ CTRL_SRCS-y += xc_private.c 65.22 CTRL_SRCS-y += xc_sedf.c 65.23 CTRL_SRCS-y += xc_csched.c 65.24 CTRL_SRCS-y += xc_tbuf.c 65.25 -CTRL_SRCS-$(CONFIG_X86) += xc_ptrace.c xc_ptrace_core.c xc_pagetab.c 65.26 +CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c 65.27 CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c 65.28 +CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c 65.29 +CTRL_SRCS-$(CONFIG_X86_Linux) += xc_ptrace.c xc_ptrace_core.c 65.30 65.31 GUEST_SRCS-y := 65.32 GUEST_SRCS-y += xc_load_bin.c 65.33 @@ -123,7 +119,7 @@ libxenctrl.so.$(MAJOR): libxenctrl.so.$( 65.34 ln -sf $< $@ 65.35 65.36 libxenctrl.so.$(MAJOR).$(MINOR): $(CTRL_PIC_OBJS) 65.37 - $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-soname -Wl,libxenctrl.so.$(MAJOR) -shared -o $@ $^ 65.38 + $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $^ 65.39 65.40 # libxenguest 65.41 65.42 @@ -136,7 +132,7 @@ libxenguest.so.$(MAJOR): libxenguest.so. 65.43 ln -sf $< $@ 65.44 65.45 libxenguest.so.$(MAJOR).$(MINOR): $(GUEST_PIC_OBJS) libxenctrl.so 65.46 - $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-soname -Wl,libxenguest.so.$(MAJOR) -shared -o $@ $^ -lz -lxenctrl 65.47 + $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenguest.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $(GUEST_PIC_OBJS) -lz -lxenctrl 65.48 65.49 -include $(DEPS) 65.50
66.1 --- a/tools/libxc/ia64/xc_ia64_linux_restore.c Sun Oct 22 14:39:15 2006 -0600 66.2 +++ b/tools/libxc/ia64/xc_ia64_linux_restore.c Sun Oct 22 15:23:52 2006 -0600 66.3 @@ -44,11 +44,11 @@ read_page(int xc_handle, int io_fd, uint 66.4 mem = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, 66.5 PROT_READ|PROT_WRITE, pfn); 66.6 if (mem == NULL) { 66.7 - ERR("cannot map page"); 66.8 + ERROR("cannot map page"); 66.9 return -1; 66.10 } 66.11 if (!read_exact(io_fd, mem, PAGE_SIZE)) { 66.12 - ERR("Error when reading from state file (5)"); 66.13 + ERROR("Error when reading from state file (5)"); 66.14 return -1; 66.15 } 66.16 munmap(mem, PAGE_SIZE); 66.17 @@ -85,17 +85,17 @@ xc_linux_restore(int xc_handle, int io_f 66.18 66.19 66.20 if (!read_exact(io_fd, &ver, sizeof(unsigned long))) { 66.21 - ERR("Error when reading version"); 66.22 + ERROR("Error when reading version"); 66.23 goto out; 66.24 } 66.25 if (ver != 1) { 66.26 - ERR("version of save doesn't match"); 66.27 + ERROR("version of save doesn't match"); 66.28 goto out; 66.29 } 66.30 66.31 if (mlock(&ctxt, sizeof(ctxt))) { 66.32 /* needed for build domctl, but might as well do early */ 66.33 - ERR("Unable to mlock ctxt"); 66.34 + ERROR("Unable to mlock ctxt"); 66.35 return 1; 66.36 } 66.37 66.38 @@ -103,7 +103,7 @@ xc_linux_restore(int xc_handle, int io_f 66.39 domctl.cmd = XEN_DOMCTL_getdomaininfo; 66.40 domctl.domain = (domid_t)dom; 66.41 if (xc_domctl(xc_handle, &domctl) < 0) { 66.42 - ERR("Could not get information on new domain"); 66.43 + ERROR("Could not get information on new domain"); 66.44 goto out; 66.45 } 66.46 shared_info_frame = domctl.u.getdomaininfo.shared_info_frame; 66.47 @@ -115,7 +115,7 @@ xc_linux_restore(int xc_handle, int io_f 66.48 66.49 if (xc_domain_memory_increase_reservation(xc_handle, dom, max_pfn, 66.50 0, 0, NULL) != 0) { 66.51 - ERR("Failed to increase reservation by %ld KB", PFN_TO_KB(max_pfn)); 66.52 + ERROR("Failed to increase reservation by %ld KB", PFN_TO_KB(max_pfn)); 66.53 errno = ENOMEM; 66.54 goto out; 66.55 } 66.56 @@ -123,7 +123,7 @@ xc_linux_restore(int xc_handle, int io_f 66.57 DPRINTF("Increased domain reservation by %ld KB\n", PFN_TO_KB(max_pfn)); 66.58 66.59 if (!read_exact(io_fd, &domctl.u.arch_setup, sizeof(domctl.u.arch_setup))) { 66.60 - ERR("read: domain setup"); 66.61 + ERROR("read: domain setup"); 66.62 goto out; 66.63 } 66.64 66.65 @@ -141,13 +141,13 @@ xc_linux_restore(int xc_handle, int io_f 66.66 /* Get pages. */ 66.67 page_array = malloc(max_pfn * sizeof(unsigned long)); 66.68 if (page_array == NULL ) { 66.69 - ERR("Could not allocate memory"); 66.70 + ERROR("Could not allocate memory"); 66.71 goto out; 66.72 } 66.73 66.74 if (xc_ia64_get_pfn_list(xc_handle, dom, page_array, 66.75 0, max_pfn) != max_pfn) { 66.76 - ERR("Could not get the page frame list"); 66.77 + ERROR("Could not get the page frame list"); 66.78 goto out; 66.79 } 66.80 66.81 @@ -155,7 +155,7 @@ xc_linux_restore(int xc_handle, int io_f 66.82 66.83 while (1) { 66.84 if (!read_exact(io_fd, &mfn, sizeof(unsigned long))) { 66.85 - ERR("Error when reading batch size"); 66.86 + ERROR("Error when reading batch size"); 66.87 goto out; 66.88 } 66.89 if (mfn == INVALID_MFN) 66.90 @@ -178,18 +178,18 @@ xc_linux_restore(int xc_handle, int io_f 66.91 int rc; 66.92 66.93 if (!read_exact(io_fd, &count, sizeof(count))) { 66.94 - ERR("Error when reading pfn count"); 66.95 + ERROR("Error when reading pfn count"); 66.96 goto out; 66.97 } 66.98 66.99 pfntab = malloc(sizeof(unsigned long) * count); 66.100 if (!pfntab) { 66.101 - ERR("Out of memory"); 66.102 + ERROR("Out of memory"); 66.103 goto out; 66.104 } 66.105 66.106 if (!read_exact(io_fd, pfntab, sizeof(unsigned long)*count)) { 66.107 - ERR("Error when reading pfntab"); 66.108 + ERROR("Error when reading pfntab"); 66.109 goto out; 66.110 } 66.111 66.112 @@ -211,7 +211,7 @@ xc_linux_restore(int xc_handle, int io_f 66.113 rc = xc_memory_op(xc_handle, XENMEM_decrease_reservation, 66.114 &reservation); 66.115 if (rc != 1) { 66.116 - ERR("Could not decrease reservation : %d", rc); 66.117 + ERROR("Could not decrease reservation : %d", rc); 66.118 goto out; 66.119 } 66.120 } 66.121 @@ -221,7 +221,7 @@ xc_linux_restore(int xc_handle, int io_f 66.122 66.123 66.124 if (!read_exact(io_fd, &ctxt, sizeof(ctxt))) { 66.125 - ERR("Error when reading ctxt"); 66.126 + ERROR("Error when reading ctxt"); 66.127 goto out; 66.128 } 66.129 66.130 @@ -234,7 +234,7 @@ xc_linux_restore(int xc_handle, int io_f 66.131 domctl.u.vcpucontext.vcpu = 0; 66.132 set_xen_guest_handle(domctl.u.vcpucontext.ctxt, &ctxt); 66.133 if (xc_domctl(xc_handle, &domctl) != 0) { 66.134 - ERR("Couldn't set vcpu context"); 66.135 + ERROR("Couldn't set vcpu context"); 66.136 goto out; 66.137 } 66.138 66.139 @@ -245,19 +245,19 @@ xc_linux_restore(int xc_handle, int io_f 66.140 domctl.u.vcpucontext.vcpu = 0; 66.141 set_xen_guest_handle(domctl.u.vcpucontext.ctxt, &ctxt); 66.142 if (xc_domctl(xc_handle, &domctl) != 0) { 66.143 - ERR("Couldn't set vcpu context"); 66.144 + ERROR("Couldn't set vcpu context"); 66.145 goto out; 66.146 } 66.147 66.148 /* Just a check. */ 66.149 if (xc_vcpu_getcontext(xc_handle, dom, 0 /* XXX */, &ctxt)) { 66.150 - ERR("Could not get vcpu context"); 66.151 + ERROR("Could not get vcpu context"); 66.152 goto out; 66.153 } 66.154 66.155 /* Then get privreg page. */ 66.156 if (read_page(xc_handle, io_fd, dom, ctxt.privregs_pfn) < 0) { 66.157 - ERR("Could not read vcpu privregs"); 66.158 + ERROR("Could not read vcpu privregs"); 66.159 goto out; 66.160 } 66.161 66.162 @@ -265,11 +265,11 @@ xc_linux_restore(int xc_handle, int io_f 66.163 shared_info = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, 66.164 PROT_READ|PROT_WRITE, shared_info_frame); 66.165 if (shared_info == NULL) { 66.166 - ERR("cannot map page"); 66.167 + ERROR("cannot map page"); 66.168 goto out; 66.169 } 66.170 if (!read_exact(io_fd, shared_info, PAGE_SIZE)) { 66.171 - ERR("Error when reading shared_info page"); 66.172 + ERROR("Error when reading shared_info page"); 66.173 goto out; 66.174 } 66.175
67.1 --- a/tools/libxc/ia64/xc_ia64_linux_save.c Sun Oct 22 14:39:15 2006 -0600 67.2 +++ b/tools/libxc/ia64/xc_ia64_linux_save.c Sun Oct 22 15:23:52 2006 -0600 67.3 @@ -97,14 +97,14 @@ suspend_and_state(int (*suspend)(int), i 67.4 int i = 0; 67.5 67.6 if (!(*suspend)(dom)) { 67.7 - ERR("Suspend request failed"); 67.8 + ERROR("Suspend request failed"); 67.9 return -1; 67.10 } 67.11 67.12 retry: 67.13 67.14 if (xc_domain_getinfo(xc_handle, dom, 1, info) != 1) { 67.15 - ERR("Could not get domain info"); 67.16 + ERROR("Could not get domain info"); 67.17 return -1; 67.18 } 67.19 67.20 @@ -115,7 +115,7 @@ retry: 67.21 // try unpausing domain, wait, and retest 67.22 xc_domain_unpause(xc_handle, dom); 67.23 67.24 - ERR("Domain was paused. Wait and re-test."); 67.25 + ERROR("Domain was paused. Wait and re-test."); 67.26 usleep(10000); // 10ms 67.27 67.28 goto retry; 67.29 @@ -123,12 +123,12 @@ retry: 67.30 67.31 67.32 if(++i < 100) { 67.33 - ERR("Retry suspend domain."); 67.34 + ERROR("Retry suspend domain."); 67.35 usleep(10000); // 10ms 67.36 goto retry; 67.37 } 67.38 67.39 - ERR("Unable to suspend domain."); 67.40 + ERROR("Unable to suspend domain."); 67.41 67.42 return -1; 67.43 } 67.44 @@ -191,7 +191,7 @@ xc_linux_save(int xc_handle, int io_fd, 67.45 //initialize_mbit_rate(); 67.46 67.47 if (xc_domain_getinfo(xc_handle, dom, 1, &info) != 1) { 67.48 - ERR("Could not get domain info"); 67.49 + ERROR("Could not get domain info"); 67.50 return 1; 67.51 } 67.52 67.53 @@ -200,7 +200,7 @@ xc_linux_save(int xc_handle, int io_fd, 67.54 #if 0 67.55 /* cheesy sanity check */ 67.56 if ((info.max_memkb >> (PAGE_SHIFT - 10)) > max_mfn) { 67.57 - ERR("Invalid state record -- pfn count out of range: %lu", 67.58 + ERROR("Invalid state record -- pfn count out of range: %lu", 67.59 (info.max_memkb >> (PAGE_SHIFT - 10))); 67.60 goto out; 67.61 } 67.62 @@ -210,7 +210,7 @@ xc_linux_save(int xc_handle, int io_fd, 67.63 live_shinfo = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, 67.64 PROT_READ, shared_info_frame); 67.65 if (!live_shinfo) { 67.66 - ERR("Couldn't map live_shinfo"); 67.67 + ERROR("Couldn't map live_shinfo"); 67.68 goto out; 67.69 } 67.70 67.71 @@ -218,13 +218,13 @@ xc_linux_save(int xc_handle, int io_fd, 67.72 67.73 page_array = malloc(max_pfn * sizeof(unsigned long)); 67.74 if (page_array == NULL) { 67.75 - ERR("Could not allocate memory"); 67.76 + ERROR("Could not allocate memory"); 67.77 goto out; 67.78 } 67.79 67.80 /* This is expected by xm restore. */ 67.81 if (!write_exact(io_fd, &max_pfn, sizeof(unsigned long))) { 67.82 - ERR("write: max_pfn"); 67.83 + ERROR("write: max_pfn"); 67.84 goto out; 67.85 } 67.86 67.87 @@ -237,7 +237,7 @@ xc_linux_save(int xc_handle, int io_fd, 67.88 unsigned long version = 1; 67.89 67.90 if (!write_exact(io_fd, &version, sizeof(unsigned long))) { 67.91 - ERR("write: version"); 67.92 + ERROR("write: version"); 67.93 goto out; 67.94 } 67.95 } 67.96 @@ -246,12 +246,12 @@ xc_linux_save(int xc_handle, int io_fd, 67.97 domctl.domain = (domid_t)dom; 67.98 domctl.u.arch_setup.flags = XEN_DOMAINSETUP_query; 67.99 if (xc_domctl(xc_handle, &domctl) < 0) { 67.100 - ERR("Could not get domain setup"); 67.101 + ERROR("Could not get domain setup"); 67.102 goto out; 67.103 } 67.104 if (!write_exact(io_fd, &domctl.u.arch_setup, 67.105 sizeof(domctl.u.arch_setup))) { 67.106 - ERR("write: domain setup"); 67.107 + ERROR("write: domain setup"); 67.108 goto out; 67.109 } 67.110 67.111 @@ -261,7 +261,7 @@ xc_linux_save(int xc_handle, int io_fd, 67.112 if (xc_ia64_shadow_control(xc_handle, dom, 67.113 XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY, 67.114 NULL, 0, NULL ) < 0) { 67.115 - ERR("Couldn't enable shadow mode"); 67.116 + ERROR("Couldn't enable shadow mode"); 67.117 goto out; 67.118 } 67.119 67.120 @@ -272,7 +272,7 @@ xc_linux_save(int xc_handle, int io_fd, 67.121 to_skip = malloc(bitmap_size); 67.122 67.123 if (!to_send || !to_skip) { 67.124 - ERR("Couldn't allocate bitmap array"); 67.125 + ERROR("Couldn't allocate bitmap array"); 67.126 goto out; 67.127 } 67.128 67.129 @@ -280,11 +280,11 @@ xc_linux_save(int xc_handle, int io_fd, 67.130 memset(to_send, 0xff, bitmap_size); 67.131 67.132 if (mlock(to_send, bitmap_size)) { 67.133 - ERR("Unable to mlock to_send"); 67.134 + ERROR("Unable to mlock to_send"); 67.135 goto out; 67.136 } 67.137 if (mlock(to_skip, bitmap_size)) { 67.138 - ERR("Unable to mlock to_skip"); 67.139 + ERROR("Unable to mlock to_skip"); 67.140 goto out; 67.141 } 67.142 67.143 @@ -296,7 +296,7 @@ xc_linux_save(int xc_handle, int io_fd, 67.144 last_iter = 1; 67.145 67.146 if (suspend_and_state(suspend, xc_handle, io_fd, dom, &info)) { 67.147 - ERR("Domain appears not to have suspended"); 67.148 + ERROR("Domain appears not to have suspended"); 67.149 goto out; 67.150 } 67.151 67.152 @@ -315,7 +315,7 @@ xc_linux_save(int xc_handle, int io_fd, 67.153 /* Get the pfn list, as it may change. */ 67.154 if (xc_ia64_get_pfn_list(xc_handle, dom, page_array, 67.155 0, max_pfn) != max_pfn) { 67.156 - ERR("Could not get the page frame list"); 67.157 + ERROR("Could not get the page frame list"); 67.158 goto out; 67.159 } 67.160 67.161 @@ -326,7 +326,7 @@ xc_linux_save(int xc_handle, int io_fd, 67.162 if (xc_ia64_shadow_control(xc_handle, dom, 67.163 XEN_DOMCTL_SHADOW_OP_PEEK, 67.164 to_skip, max_pfn, NULL) != max_pfn) { 67.165 - ERR("Error peeking shadow bitmap"); 67.166 + ERROR("Error peeking shadow bitmap"); 67.167 goto out; 67.168 } 67.169 } 67.170 @@ -358,12 +358,12 @@ xc_linux_save(int xc_handle, int io_fd, 67.171 } 67.172 67.173 if (!write_exact(io_fd, &N, sizeof(N))) { 67.174 - ERR("write: max_pfn"); 67.175 + ERROR("write: max_pfn"); 67.176 goto out; 67.177 } 67.178 67.179 if (write(io_fd, mem, PAGE_SIZE) != PAGE_SIZE) { 67.180 - ERR("Error when writing to state file (5)"); 67.181 + ERROR("Error when writing to state file (5)"); 67.182 goto out; 67.183 } 67.184 munmap(mem, PAGE_SIZE); 67.185 @@ -385,7 +385,7 @@ xc_linux_save(int xc_handle, int io_fd, 67.186 last_iter = 1; 67.187 67.188 if (suspend_and_state(suspend, xc_handle, io_fd, dom, &info)) { 67.189 - ERR("Domain appears not to have suspended"); 67.190 + ERROR("Domain appears not to have suspended"); 67.191 goto out; 67.192 } 67.193 } 67.194 @@ -394,7 +394,7 @@ xc_linux_save(int xc_handle, int io_fd, 67.195 if (xc_ia64_shadow_control(xc_handle, dom, 67.196 XEN_DOMCTL_SHADOW_OP_CLEAN, 67.197 to_send, max_pfn, NULL ) != max_pfn) { 67.198 - ERR("Error flushing shadow PT"); 67.199 + ERROR("Error flushing shadow PT"); 67.200 goto out; 67.201 } 67.202 67.203 @@ -411,7 +411,7 @@ xc_linux_save(int xc_handle, int io_fd, 67.204 { 67.205 unsigned long pfn = INVALID_MFN; 67.206 if (!write_exact(io_fd, &pfn, sizeof(pfn))) { 67.207 - ERR("Error when writing to state file (6)"); 67.208 + ERROR("Error when writing to state file (6)"); 67.209 goto out; 67.210 } 67.211 } 67.212 @@ -427,7 +427,7 @@ xc_linux_save(int xc_handle, int io_fd, 67.213 } 67.214 67.215 if (!write_exact(io_fd, &j, sizeof(unsigned int))) { 67.216 - ERR("Error when writing to state file (6a)"); 67.217 + ERROR("Error when writing to state file (6a)"); 67.218 goto out; 67.219 } 67.220 67.221 @@ -439,7 +439,7 @@ xc_linux_save(int xc_handle, int io_fd, 67.222 i++; 67.223 if (j == 1024 || i == max_pfn) { 67.224 if (!write_exact(io_fd, &pfntab, sizeof(unsigned long)*j)) { 67.225 - ERR("Error when writing to state file (6b)"); 67.226 + ERROR("Error when writing to state file (6b)"); 67.227 goto out; 67.228 } 67.229 j = 0; 67.230 @@ -449,12 +449,12 @@ xc_linux_save(int xc_handle, int io_fd, 67.231 } 67.232 67.233 if (xc_vcpu_getcontext(xc_handle, dom, 0, &ctxt)) { 67.234 - ERR("Could not get vcpu context"); 67.235 + ERROR("Could not get vcpu context"); 67.236 goto out; 67.237 } 67.238 67.239 if (!write_exact(io_fd, &ctxt, sizeof(ctxt))) { 67.240 - ERR("Error when writing to state file (1)"); 67.241 + ERROR("Error when writing to state file (1)"); 67.242 goto out; 67.243 } 67.244 67.245 @@ -464,17 +464,17 @@ xc_linux_save(int xc_handle, int io_fd, 67.246 mem = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, 67.247 PROT_READ|PROT_WRITE, ctxt.privregs_pfn); 67.248 if (mem == NULL) { 67.249 - ERR("cannot map privreg page"); 67.250 + ERROR("cannot map privreg page"); 67.251 goto out; 67.252 } 67.253 if (write(io_fd, mem, PAGE_SIZE) != PAGE_SIZE) { 67.254 - ERR("Error when writing privreg to state file (5)"); 67.255 + ERROR("Error when writing privreg to state file (5)"); 67.256 goto out; 67.257 } 67.258 munmap(mem, PAGE_SIZE); 67.259 67.260 if (!write_exact(io_fd, live_shinfo, PAGE_SIZE)) { 67.261 - ERR("Error when writing to state file (1)"); 67.262 + ERROR("Error when writing to state file (1)"); 67.263 goto out; 67.264 } 67.265
68.1 --- a/tools/libxc/xc_hvm_build.c Sun Oct 22 14:39:15 2006 -0600 68.2 +++ b/tools/libxc/xc_hvm_build.c Sun Oct 22 15:23:52 2006 -0600 68.3 @@ -17,7 +17,6 @@ 68.4 #include <xen/hvm/e820.h> 68.5 68.6 #define HVM_LOADER_ENTR_ADDR 0x00100000 68.7 - 68.8 static int 68.9 parseelfimage( 68.10 char *elfbase, unsigned long elfsize, struct domain_setup_info *dsi); 68.11 @@ -82,15 +81,16 @@ static void build_e820map(void *e820_pag 68.12 e820entry[nr_map].type = E820_IO; 68.13 nr_map++; 68.14 68.15 + e820entry[nr_map].addr = 0xEA000; 68.16 + e820entry[nr_map].size = 0x01000; 68.17 + e820entry[nr_map].type = E820_ACPI; 68.18 + nr_map++; 68.19 + 68.20 e820entry[nr_map].addr = 0xF0000; 68.21 e820entry[nr_map].size = 0x10000; 68.22 e820entry[nr_map].type = E820_RESERVED; 68.23 nr_map++; 68.24 68.25 -/* ACPI data: 10 pages. */ 68.26 -#define ACPI_DATA_PAGES 10 68.27 -/* ACPI NVS: 3 pages. */ 68.28 -#define ACPI_NVS_PAGES 3 68.29 /* buffered io page. */ 68.30 #define BUFFERED_IO_PAGES 1 68.31 /* xenstore page. */ 68.32 @@ -102,9 +102,7 @@ static void build_e820map(void *e820_pag 68.33 /* Most of the ram goes here */ 68.34 e820entry[nr_map].addr = 0x100000; 68.35 e820entry[nr_map].size = mem_size - 0x100000 - PAGE_SIZE * 68.36 - (ACPI_DATA_PAGES + 68.37 - ACPI_NVS_PAGES + 68.38 - BUFFERED_IO_PAGES + 68.39 + (BUFFERED_IO_PAGES + 68.40 XENSTORE_PAGES + 68.41 SHARED_IO_PAGES); 68.42 e820entry[nr_map].type = E820_RAM; 68.43 @@ -112,27 +110,6 @@ static void build_e820map(void *e820_pag 68.44 68.45 /* Statically allocated special pages */ 68.46 68.47 - /* For ACPI data */ 68.48 - e820entry[nr_map].addr = mem_size - PAGE_SIZE * 68.49 - (ACPI_DATA_PAGES + 68.50 - ACPI_NVS_PAGES + 68.51 - BUFFERED_IO_PAGES + 68.52 - XENSTORE_PAGES + 68.53 - SHARED_IO_PAGES); 68.54 - e820entry[nr_map].size = PAGE_SIZE * ACPI_DATA_PAGES; 68.55 - e820entry[nr_map].type = E820_ACPI; 68.56 - nr_map++; 68.57 - 68.58 - /* For ACPI NVS */ 68.59 - e820entry[nr_map].addr = mem_size - PAGE_SIZE * 68.60 - (ACPI_NVS_PAGES + 68.61 - BUFFERED_IO_PAGES + 68.62 - XENSTORE_PAGES + 68.63 - SHARED_IO_PAGES); 68.64 - e820entry[nr_map].size = PAGE_SIZE * ACPI_NVS_PAGES; 68.65 - e820entry[nr_map].type = E820_NVS; 68.66 - nr_map++; 68.67 - 68.68 /* For buffered IO requests */ 68.69 e820entry[nr_map].addr = mem_size - PAGE_SIZE * 68.70 (BUFFERED_IO_PAGES +
69.1 --- a/tools/libxc/xc_linux_restore.c Sun Oct 22 14:39:15 2006 -0600 69.2 +++ b/tools/libxc/xc_linux_restore.c Sun Oct 22 15:23:52 2006 -0600 69.3 @@ -79,7 +79,7 @@ int uncanonicalize_pagetable(unsigned lo 69.4 69.5 if(pfn >= max_pfn) { 69.6 /* This "page table page" is probably not one; bail. */ 69.7 - ERR("Frame number in type %lu page table is out of range: " 69.8 + ERROR("Frame number in type %lu page table is out of range: " 69.9 "i=%d pfn=0x%lx max_pfn=%lu", 69.10 type >> 28, i, pfn, max_pfn); 69.11 return 0; 69.12 @@ -158,24 +158,24 @@ int xc_linux_restore(int xc_handle, int 69.13 69.14 if(!get_platform_info(xc_handle, dom, 69.15 &max_mfn, &hvirt_start, &pt_levels)) { 69.16 - ERR("Unable to get platform info."); 69.17 + ERROR("Unable to get platform info."); 69.18 return 1; 69.19 } 69.20 69.21 if (mlock(&ctxt, sizeof(ctxt))) { 69.22 /* needed for build domctl, but might as well do early */ 69.23 - ERR("Unable to mlock ctxt"); 69.24 + ERROR("Unable to mlock ctxt"); 69.25 return 1; 69.26 } 69.27 69.28 if (!(p2m_frame_list = malloc(P2M_FL_SIZE))) { 69.29 - ERR("Couldn't allocate p2m_frame_list array"); 69.30 + ERROR("Couldn't allocate p2m_frame_list array"); 69.31 goto out; 69.32 } 69.33 69.34 /* Read first entry of P2M list, or extended-info signature (~0UL). */ 69.35 if (!read_exact(io_fd, p2m_frame_list, sizeof(long))) { 69.36 - ERR("read extended-info signature failed"); 69.37 + ERROR("read extended-info signature failed"); 69.38 goto out; 69.39 } 69.40 69.41 @@ -184,7 +184,7 @@ int xc_linux_restore(int xc_handle, int 69.42 69.43 /* Next 4 bytes: total size of following extended info. */ 69.44 if (!read_exact(io_fd, &tot_bytes, sizeof(tot_bytes))) { 69.45 - ERR("read extended-info size failed"); 69.46 + ERROR("read extended-info size failed"); 69.47 goto out; 69.48 } 69.49 69.50 @@ -195,7 +195,7 @@ int xc_linux_restore(int xc_handle, int 69.51 /* 4-character chunk signature + 4-byte remaining chunk size. */ 69.52 if (!read_exact(io_fd, chunk_sig, sizeof(chunk_sig)) || 69.53 !read_exact(io_fd, &chunk_bytes, sizeof(chunk_bytes))) { 69.54 - ERR("read extended-info chunk signature failed"); 69.55 + ERROR("read extended-info chunk signature failed"); 69.56 goto out; 69.57 } 69.58 tot_bytes -= 8; 69.59 @@ -203,7 +203,7 @@ int xc_linux_restore(int xc_handle, int 69.60 /* VCPU context structure? */ 69.61 if (!strncmp(chunk_sig, "vcpu", 4)) { 69.62 if (!read_exact(io_fd, &ctxt, sizeof(ctxt))) { 69.63 - ERR("read extended-info vcpu context failed"); 69.64 + ERROR("read extended-info vcpu context failed"); 69.65 goto out; 69.66 } 69.67 tot_bytes -= sizeof(struct vcpu_guest_context); 69.68 @@ -219,7 +219,7 @@ int xc_linux_restore(int xc_handle, int 69.69 if ( sz > P2M_FL_SIZE ) 69.70 sz = P2M_FL_SIZE; 69.71 if (!read_exact(io_fd, p2m_frame_list, sz)) { 69.72 - ERR("read-and-discard extended-info chunk bytes failed"); 69.73 + ERROR("read-and-discard extended-info chunk bytes failed"); 69.74 goto out; 69.75 } 69.76 chunk_bytes -= sz; 69.77 @@ -229,14 +229,14 @@ int xc_linux_restore(int xc_handle, int 69.78 69.79 /* Now read the real first entry of P2M list. */ 69.80 if (!read_exact(io_fd, p2m_frame_list, sizeof(long))) { 69.81 - ERR("read first entry of p2m_frame_list failed"); 69.82 + ERROR("read first entry of p2m_frame_list failed"); 69.83 goto out; 69.84 } 69.85 } 69.86 69.87 /* First entry is already read into the p2m array. */ 69.88 if (!read_exact(io_fd, &p2m_frame_list[1], P2M_FL_SIZE - sizeof(long))) { 69.89 - ERR("read p2m_frame_list failed"); 69.90 + ERROR("read p2m_frame_list failed"); 69.91 goto out; 69.92 } 69.93 69.94 @@ -246,13 +246,13 @@ int xc_linux_restore(int xc_handle, int 69.95 region_mfn = calloc(MAX_BATCH_SIZE, sizeof(xen_pfn_t)); 69.96 69.97 if ((p2m == NULL) || (pfn_type == NULL) || (region_mfn == NULL)) { 69.98 - ERR("memory alloc failed"); 69.99 + ERROR("memory alloc failed"); 69.100 errno = ENOMEM; 69.101 goto out; 69.102 } 69.103 69.104 if (mlock(region_mfn, sizeof(xen_pfn_t) * MAX_BATCH_SIZE)) { 69.105 - ERR("Could not mlock region_mfn"); 69.106 + ERROR("Could not mlock region_mfn"); 69.107 goto out; 69.108 } 69.109 69.110 @@ -260,7 +260,7 @@ int xc_linux_restore(int xc_handle, int 69.111 domctl.cmd = XEN_DOMCTL_getdomaininfo; 69.112 domctl.domain = (domid_t)dom; 69.113 if (xc_domctl(xc_handle, &domctl) < 0) { 69.114 - ERR("Could not get information on new domain"); 69.115 + ERROR("Could not get information on new domain"); 69.116 goto out; 69.117 } 69.118 shared_info_frame = domctl.u.getdomaininfo.shared_info_frame; 69.119 @@ -272,7 +272,7 @@ int xc_linux_restore(int xc_handle, int 69.120 69.121 if(xc_domain_memory_increase_reservation( 69.122 xc_handle, dom, max_pfn, 0, 0, NULL) != 0) { 69.123 - ERR("Failed to increase reservation by %lx KB", PFN_TO_KB(max_pfn)); 69.124 + ERROR("Failed to increase reservation by %lx KB", PFN_TO_KB(max_pfn)); 69.125 errno = ENOMEM; 69.126 goto out; 69.127 } 69.128 @@ -281,12 +281,12 @@ int xc_linux_restore(int xc_handle, int 69.129 69.130 /* Build the pfn-to-mfn table. We choose MFN ordering returned by Xen. */ 69.131 if (xc_get_pfn_list(xc_handle, dom, p2m, max_pfn) != max_pfn) { 69.132 - ERR("Did not read correct number of frame numbers for new dom"); 69.133 + ERROR("Did not read correct number of frame numbers for new dom"); 69.134 goto out; 69.135 } 69.136 69.137 if(!(mmu = xc_init_mmu_updates(xc_handle, dom))) { 69.138 - ERR("Could not initialise for MMU updates"); 69.139 + ERROR("Could not initialise for MMU updates"); 69.140 goto out; 69.141 } 69.142 69.143 @@ -312,7 +312,7 @@ int xc_linux_restore(int xc_handle, int 69.144 } 69.145 69.146 if (!read_exact(io_fd, &j, sizeof(int))) { 69.147 - ERR("Error when reading batch size"); 69.148 + ERROR("Error when reading batch size"); 69.149 goto out; 69.150 } 69.151 69.152 @@ -328,12 +328,12 @@ int xc_linux_restore(int xc_handle, int 69.153 break; /* our work here is done */ 69.154 69.155 if (j > MAX_BATCH_SIZE) { 69.156 - ERR("Max batch size exceeded. Giving up."); 69.157 + ERROR("Max batch size exceeded. Giving up."); 69.158 goto out; 69.159 } 69.160 69.161 if (!read_exact(io_fd, region_pfn_type, j*sizeof(unsigned long))) { 69.162 - ERR("Error when reading region pfn types"); 69.163 + ERROR("Error when reading region pfn types"); 69.164 goto out; 69.165 } 69.166 69.167 @@ -353,7 +353,7 @@ int xc_linux_restore(int xc_handle, int 69.168 xc_handle, dom, PROT_WRITE, region_mfn, j); 69.169 if ( region_base == NULL ) 69.170 { 69.171 - ERR("map batch failed"); 69.172 + ERROR("map batch failed"); 69.173 goto out; 69.174 } 69.175 69.176 @@ -371,7 +371,7 @@ int xc_linux_restore(int xc_handle, int 69.177 69.178 if ( pfn > max_pfn ) 69.179 { 69.180 - ERR("pfn out of range"); 69.181 + ERROR("pfn out of range"); 69.182 goto out; 69.183 } 69.184 69.185 @@ -383,7 +383,7 @@ int xc_linux_restore(int xc_handle, int 69.186 page = verify ? (void *)buf : (region_base + i*PAGE_SIZE); 69.187 69.188 if (!read_exact(io_fd, page, PAGE_SIZE)) { 69.189 - ERR("Error when reading page (type was %lx)", pagetype); 69.190 + ERROR("Error when reading page (type was %lx)", pagetype); 69.191 goto out; 69.192 } 69.193 69.194 @@ -422,7 +422,7 @@ int xc_linux_restore(int xc_handle, int 69.195 } 69.196 else if ( pagetype != XEN_DOMCTL_PFINFO_NOTAB ) 69.197 { 69.198 - ERR("Bogus page type %lx page table is out of range: " 69.199 + ERROR("Bogus page type %lx page table is out of range: " 69.200 "i=%d max_pfn=%lu", pagetype, i, max_pfn); 69.201 goto out; 69.202 69.203 @@ -455,7 +455,7 @@ int xc_linux_restore(int xc_handle, int 69.204 if (xc_add_mmu_update(xc_handle, mmu, 69.205 (((unsigned long long)mfn) << PAGE_SHIFT) 69.206 | MMU_MACHPHYS_UPDATE, pfn)) { 69.207 - ERR("failed machpys update mfn=%lx pfn=%lx", mfn, pfn); 69.208 + ERROR("failed machpys update mfn=%lx pfn=%lx", mfn, pfn); 69.209 goto out; 69.210 } 69.211 } /* end of 'batch' for loop */ 69.212 @@ -469,7 +469,7 @@ int xc_linux_restore(int xc_handle, int 69.213 * reallocations below. 69.214 */ 69.215 if (xc_finish_mmu_updates(xc_handle, mmu)) { 69.216 - ERR("Error doing finish_mmu_updates()"); 69.217 + ERROR("Error doing finish_mmu_updates()"); 69.218 goto out; 69.219 } 69.220 69.221 @@ -512,7 +512,7 @@ int xc_linux_restore(int xc_handle, int 69.222 munmap(l3tab, PAGE_SIZE); 69.223 69.224 if (!(new_mfn=xc_make_page_below_4G(xc_handle, dom, p2m[i]))) { 69.225 - ERR("Couldn't get a page below 4GB :-("); 69.226 + ERROR("Couldn't get a page below 4GB :-("); 69.227 goto out; 69.228 } 69.229 69.230 @@ -521,7 +521,7 @@ int xc_linux_restore(int xc_handle, int 69.231 (((unsigned long long)new_mfn) 69.232 << PAGE_SHIFT) | 69.233 MMU_MACHPHYS_UPDATE, i)) { 69.234 - ERR("Couldn't m2p on PAE root pgdir"); 69.235 + ERROR("Couldn't m2p on PAE root pgdir"); 69.236 goto out; 69.237 } 69.238 69.239 @@ -554,14 +554,14 @@ int xc_linux_restore(int xc_handle, int 69.240 if (!(region_base = xc_map_foreign_batch( 69.241 xc_handle, dom, PROT_READ | PROT_WRITE, 69.242 region_mfn, j))) { 69.243 - ERR("map batch failed"); 69.244 + ERROR("map batch failed"); 69.245 goto out; 69.246 } 69.247 69.248 for(k = 0; k < j; k++) { 69.249 if(!uncanonicalize_pagetable(XEN_DOMCTL_PFINFO_L1TAB, 69.250 region_base + k*PAGE_SIZE)) { 69.251 - ERR("failed uncanonicalize pt!"); 69.252 + ERROR("failed uncanonicalize pt!"); 69.253 goto out; 69.254 } 69.255 } 69.256 @@ -572,7 +572,7 @@ int xc_linux_restore(int xc_handle, int 69.257 } 69.258 69.259 if (xc_finish_mmu_updates(xc_handle, mmu)) { 69.260 - ERR("Error doing finish_mmu_updates()"); 69.261 + ERROR("Error doing finish_mmu_updates()"); 69.262 goto out; 69.263 } 69.264 } 69.265 @@ -615,7 +615,7 @@ int xc_linux_restore(int xc_handle, int 69.266 /* Batch full? Then flush. */ 69.267 if (nr_pins == MAX_PIN_BATCH) { 69.268 if (xc_mmuext_op(xc_handle, pin, nr_pins, dom) < 0) { 69.269 - ERR("Failed to pin batch of %d page tables", nr_pins); 69.270 + ERROR("Failed to pin batch of %d page tables", nr_pins); 69.271 goto out; 69.272 } 69.273 nr_pins = 0; 69.274 @@ -624,7 +624,7 @@ int xc_linux_restore(int xc_handle, int 69.275 69.276 /* Flush final partial batch. */ 69.277 if ((nr_pins != 0) && (xc_mmuext_op(xc_handle, pin, nr_pins, dom) < 0)) { 69.278 - ERR("Failed to pin batch of %d page tables", nr_pins); 69.279 + ERROR("Failed to pin batch of %d page tables", nr_pins); 69.280 goto out; 69.281 } 69.282 69.283 @@ -638,17 +638,17 @@ int xc_linux_restore(int xc_handle, int 69.284 int rc; 69.285 69.286 if (!read_exact(io_fd, &count, sizeof(count))) { 69.287 - ERR("Error when reading pfn count"); 69.288 + ERROR("Error when reading pfn count"); 69.289 goto out; 69.290 } 69.291 69.292 if(!(pfntab = malloc(sizeof(unsigned long) * count))) { 69.293 - ERR("Out of memory"); 69.294 + ERROR("Out of memory"); 69.295 goto out; 69.296 } 69.297 69.298 if (!read_exact(io_fd, pfntab, sizeof(unsigned long)*count)) { 69.299 - ERR("Error when reading pfntab"); 69.300 + ERROR("Error when reading pfntab"); 69.301 goto out; 69.302 } 69.303 69.304 @@ -675,7 +675,7 @@ int xc_linux_restore(int xc_handle, int 69.305 69.306 if ((rc = xc_memory_op(xc_handle, XENMEM_decrease_reservation, 69.307 &reservation)) != count) { 69.308 - ERR("Could not decrease reservation : %d", rc); 69.309 + ERROR("Could not decrease reservation : %d", rc); 69.310 goto out; 69.311 } else 69.312 DPRINTF("Decreased reservation by %d pages\n", count); 69.313 @@ -684,14 +684,14 @@ int xc_linux_restore(int xc_handle, int 69.314 69.315 if (!read_exact(io_fd, &ctxt, sizeof(ctxt)) || 69.316 !read_exact(io_fd, shared_info_page, PAGE_SIZE)) { 69.317 - ERR("Error when reading ctxt or shared info page"); 69.318 + ERROR("Error when reading ctxt or shared info page"); 69.319 goto out; 69.320 } 69.321 69.322 /* Uncanonicalise the suspend-record frame number and poke resume rec. */ 69.323 pfn = ctxt.user_regs.edx; 69.324 if ((pfn >= max_pfn) || (pfn_type[pfn] != XEN_DOMCTL_PFINFO_NOTAB)) { 69.325 - ERR("Suspend record frame number is bad"); 69.326 + ERROR("Suspend record frame number is bad"); 69.327 goto out; 69.328 } 69.329 ctxt.user_regs.edx = mfn = p2m[pfn]; 69.330 @@ -709,14 +709,14 @@ int xc_linux_restore(int xc_handle, int 69.331 69.332 /* Uncanonicalise each GDT frame number. */ 69.333 if (ctxt.gdt_ents > 8192) { 69.334 - ERR("GDT entry count out of range"); 69.335 + ERROR("GDT entry count out of range"); 69.336 goto out; 69.337 } 69.338 69.339 for (i = 0; i < ctxt.gdt_ents; i += 512) { 69.340 pfn = ctxt.gdt_frames[i]; 69.341 if ((pfn >= max_pfn) || (pfn_type[pfn] != XEN_DOMCTL_PFINFO_NOTAB)) { 69.342 - ERR("GDT frame number is bad"); 69.343 + ERROR("GDT frame number is bad"); 69.344 goto out; 69.345 } 69.346 ctxt.gdt_frames[i] = p2m[pfn]; 69.347 @@ -726,14 +726,14 @@ int xc_linux_restore(int xc_handle, int 69.348 pfn = xen_cr3_to_pfn(ctxt.ctrlreg[3]); 69.349 69.350 if (pfn >= max_pfn) { 69.351 - ERR("PT base is bad: pfn=%lu max_pfn=%lu type=%08lx", 69.352 + ERROR("PT base is bad: pfn=%lu max_pfn=%lu type=%08lx", 69.353 pfn, max_pfn, pfn_type[pfn]); 69.354 goto out; 69.355 } 69.356 69.357 if ( (pfn_type[pfn] & XEN_DOMCTL_PFINFO_LTABTYPE_MASK) != 69.358 ((unsigned long)pt_levels<<XEN_DOMCTL_PFINFO_LTAB_SHIFT) ) { 69.359 - ERR("PT base is bad. pfn=%lu nr=%lu type=%08lx %08lx", 69.360 + ERROR("PT base is bad. pfn=%lu nr=%lu type=%08lx %08lx", 69.361 pfn, max_pfn, pfn_type[pfn], 69.362 (unsigned long)pt_levels<<XEN_DOMCTL_PFINFO_LTAB_SHIFT); 69.363 goto out; 69.364 @@ -757,7 +757,7 @@ int xc_linux_restore(int xc_handle, int 69.365 for (i = 0; i < P2M_FL_ENTRIES; i++) { 69.366 pfn = p2m_frame_list[i]; 69.367 if ((pfn >= max_pfn) || (pfn_type[pfn] != XEN_DOMCTL_PFINFO_NOTAB)) { 69.368 - ERR("PFN-to-MFN frame number is bad"); 69.369 + ERROR("PFN-to-MFN frame number is bad"); 69.370 goto out; 69.371 } 69.372 69.373 @@ -767,7 +767,7 @@ int xc_linux_restore(int xc_handle, int 69.374 /* Copy the P2M we've constructed to the 'live' P2M */ 69.375 if (!(live_p2m = xc_map_foreign_batch(xc_handle, dom, PROT_WRITE, 69.376 p2m_frame_list, P2M_FL_ENTRIES))) { 69.377 - ERR("Couldn't map p2m table"); 69.378 + ERROR("Couldn't map p2m table"); 69.379 goto out; 69.380 } 69.381 69.382 @@ -803,7 +803,7 @@ int xc_linux_restore(int xc_handle, int 69.383 (ctxt.ldt_ents > 8192) || 69.384 (ctxt.ldt_base > hvirt_start) || 69.385 ((ctxt.ldt_base + ctxt.ldt_ents*8) > hvirt_start)) { 69.386 - ERR("Bad LDT base or size"); 69.387 + ERROR("Bad LDT base or size"); 69.388 goto out; 69.389 } 69.390 69.391 @@ -816,7 +816,7 @@ int xc_linux_restore(int xc_handle, int 69.392 rc = xc_domctl(xc_handle, &domctl); 69.393 69.394 if (rc != 0) { 69.395 - ERR("Couldn't build the domain"); 69.396 + ERROR("Couldn't build the domain"); 69.397 goto out; 69.398 } 69.399
70.1 --- a/tools/libxc/xc_linux_save.c Sun Oct 22 14:39:15 2006 -0600 70.2 +++ b/tools/libxc/xc_linux_save.c Sun Oct 22 15:23:52 2006 -0600 70.3 @@ -363,19 +363,19 @@ static int suspend_and_state(int (*suspe 70.4 int i = 0; 70.5 70.6 if (!(*suspend)(dom)) { 70.7 - ERR("Suspend request failed"); 70.8 + ERROR("Suspend request failed"); 70.9 return -1; 70.10 } 70.11 70.12 retry: 70.13 70.14 if (xc_domain_getinfo(xc_handle, dom, 1, info) != 1) { 70.15 - ERR("Could not get domain info"); 70.16 + ERROR("Could not get domain info"); 70.17 return -1; 70.18 } 70.19 70.20 if ( xc_vcpu_getcontext(xc_handle, dom, 0 /* XXX */, ctxt)) 70.21 - ERR("Could not get vcpu context"); 70.22 + ERROR("Could not get vcpu context"); 70.23 70.24 70.25 if (info->shutdown && info->shutdown_reason == SHUTDOWN_suspend) 70.26 @@ -385,7 +385,7 @@ static int suspend_and_state(int (*suspe 70.27 // try unpausing domain, wait, and retest 70.28 xc_domain_unpause( xc_handle, dom ); 70.29 70.30 - ERR("Domain was paused. Wait and re-test."); 70.31 + ERROR("Domain was paused. Wait and re-test."); 70.32 usleep(10000); // 10ms 70.33 70.34 goto retry; 70.35 @@ -393,12 +393,12 @@ static int suspend_and_state(int (*suspe 70.36 70.37 70.38 if( ++i < 100 ) { 70.39 - ERR("Retry suspend domain."); 70.40 + ERROR("Retry suspend domain."); 70.41 usleep(10000); // 10ms 70.42 goto retry; 70.43 } 70.44 70.45 - ERR("Unable to suspend domain."); 70.46 + ERROR("Unable to suspend domain."); 70.47 70.48 return -1; 70.49 } 70.50 @@ -516,25 +516,25 @@ static xen_pfn_t *xc_map_m2p(int xc_hand 70.51 70.52 xmml.max_extents = m2p_chunks; 70.53 if (!(extent_start = malloc(m2p_chunks * sizeof(xen_pfn_t)))) { 70.54 - ERR("failed to allocate space for m2p mfns"); 70.55 + ERROR("failed to allocate space for m2p mfns"); 70.56 return NULL; 70.57 } 70.58 set_xen_guest_handle(xmml.extent_start, extent_start); 70.59 70.60 if (xc_memory_op(xc_handle, XENMEM_machphys_mfn_list, &xmml) || 70.61 (xmml.nr_extents != m2p_chunks)) { 70.62 - ERR("xc_get_m2p_mfns"); 70.63 + ERROR("xc_get_m2p_mfns"); 70.64 return NULL; 70.65 } 70.66 70.67 if ((m2p = mmap(NULL, m2p_size, prot, 70.68 MAP_SHARED, xc_handle, 0)) == MAP_FAILED) { 70.69 - ERR("failed to mmap m2p"); 70.70 + ERROR("failed to mmap m2p"); 70.71 return NULL; 70.72 } 70.73 70.74 if (!(entries = malloc(m2p_chunks * sizeof(privcmd_mmap_entry_t)))) { 70.75 - ERR("failed to allocate space for mmap entries"); 70.76 + ERROR("failed to allocate space for mmap entries"); 70.77 return NULL; 70.78 } 70.79 70.80 @@ -546,7 +546,7 @@ static xen_pfn_t *xc_map_m2p(int xc_hand 70.81 70.82 if ((rc = xc_map_foreign_ranges(xc_handle, DOMID_XEN, 70.83 entries, m2p_chunks)) < 0) { 70.84 - ERR("xc_mmap_foreign_ranges failed (rc = %d)", rc); 70.85 + ERROR("xc_mmap_foreign_ranges failed (rc = %d)", rc); 70.86 return NULL; 70.87 } 70.88 70.89 @@ -619,23 +619,23 @@ int xc_linux_save(int xc_handle, int io_ 70.90 70.91 if(!get_platform_info(xc_handle, dom, 70.92 &max_mfn, &hvirt_start, &pt_levels)) { 70.93 - ERR("Unable to get platform info."); 70.94 + ERROR("Unable to get platform info."); 70.95 return 1; 70.96 } 70.97 70.98 if (xc_domain_getinfo(xc_handle, dom, 1, &info) != 1) { 70.99 - ERR("Could not get domain info"); 70.100 + ERROR("Could not get domain info"); 70.101 return 1; 70.102 } 70.103 70.104 if (mlock(&ctxt, sizeof(ctxt))) { 70.105 - ERR("Unable to mlock ctxt"); 70.106 + ERROR("Unable to mlock ctxt"); 70.107 return 1; 70.108 } 70.109 70.110 /* Only have to worry about vcpu 0 even for SMP */ 70.111 if (xc_vcpu_getcontext(xc_handle, dom, 0, &ctxt)) { 70.112 - ERR("Could not get vcpu context"); 70.113 + ERROR("Could not get vcpu context"); 70.114 goto out; 70.115 } 70.116 shared_info_frame = info.shared_info_frame; 70.117 @@ -643,13 +643,13 @@ int xc_linux_save(int xc_handle, int io_ 70.118 /* A cheesy test to see whether the domain contains valid state. */ 70.119 if (ctxt.ctrlreg[3] == 0) 70.120 { 70.121 - ERR("Domain is not in a valid Linux guest OS state"); 70.122 + ERROR("Domain is not in a valid Linux guest OS state"); 70.123 goto out; 70.124 } 70.125 70.126 /* cheesy sanity check */ 70.127 if ((info.max_memkb >> (PAGE_SHIFT - 10)) > max_mfn) { 70.128 - ERR("Invalid state record -- pfn count out of range: %lu", 70.129 + ERROR("Invalid state record -- pfn count out of range: %lu", 70.130 (info.max_memkb >> (PAGE_SHIFT - 10))); 70.131 goto out; 70.132 } 70.133 @@ -657,7 +657,7 @@ int xc_linux_save(int xc_handle, int io_ 70.134 /* Map the shared info frame */ 70.135 if(!(live_shinfo = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, 70.136 PROT_READ, shared_info_frame))) { 70.137 - ERR("Couldn't map live_shinfo"); 70.138 + ERROR("Couldn't map live_shinfo"); 70.139 goto out; 70.140 } 70.141 70.142 @@ -668,7 +668,7 @@ int xc_linux_save(int xc_handle, int io_ 70.143 live_shinfo->arch.pfn_to_mfn_frame_list_list); 70.144 70.145 if (!live_p2m_frame_list_list) { 70.146 - ERR("Couldn't map p2m_frame_list_list (errno %d)", errno); 70.147 + ERROR("Couldn't map p2m_frame_list_list (errno %d)", errno); 70.148 goto out; 70.149 } 70.150 70.151 @@ -678,7 +678,7 @@ int xc_linux_save(int xc_handle, int io_ 70.152 P2M_FLL_ENTRIES); 70.153 70.154 if (!live_p2m_frame_list) { 70.155 - ERR("Couldn't map p2m_frame_list"); 70.156 + ERROR("Couldn't map p2m_frame_list"); 70.157 goto out; 70.158 } 70.159 70.160 @@ -692,20 +692,20 @@ int xc_linux_save(int xc_handle, int io_ 70.161 P2M_FL_ENTRIES); 70.162 70.163 if (!live_p2m) { 70.164 - ERR("Couldn't map p2m table"); 70.165 + ERROR("Couldn't map p2m table"); 70.166 goto out; 70.167 } 70.168 70.169 /* Setup the mfn_to_pfn table mapping */ 70.170 if(!(live_m2p = xc_map_m2p(xc_handle, max_mfn, PROT_READ))) { 70.171 - ERR("Failed to map live M2P table"); 70.172 + ERROR("Failed to map live M2P table"); 70.173 goto out; 70.174 } 70.175 70.176 70.177 /* Get a local copy of the live_P2M_frame_list */ 70.178 if(!(p2m_frame_list = malloc(P2M_FL_SIZE))) { 70.179 - ERR("Couldn't allocate p2m_frame_list array"); 70.180 + ERROR("Couldn't allocate p2m_frame_list array"); 70.181 goto out; 70.182 } 70.183 memcpy(p2m_frame_list, live_p2m_frame_list, P2M_FL_SIZE); 70.184 @@ -713,8 +713,8 @@ int xc_linux_save(int xc_handle, int io_ 70.185 /* Canonicalise the pfn-to-mfn table frame-number list. */ 70.186 for (i = 0; i < max_pfn; i += fpp) { 70.187 if (!translate_mfn_to_pfn(&p2m_frame_list[i/fpp])) { 70.188 - ERR("Frame# in pfn-to-mfn frame list is not in pseudophys"); 70.189 - ERR("entry %d: p2m_frame_list[%ld] is 0x%"PRIx64, i, i/fpp, 70.190 + ERROR("Frame# in pfn-to-mfn frame list is not in pseudophys"); 70.191 + ERROR("entry %d: p2m_frame_list[%ld] is 0x%"PRIx64, i, i/fpp, 70.192 (uint64_t)p2m_frame_list[i/fpp]); 70.193 goto out; 70.194 } 70.195 @@ -726,7 +726,7 @@ int xc_linux_save(int xc_handle, int io_ 70.196 if (xc_shadow_control(xc_handle, dom, 70.197 XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY, 70.198 NULL, 0, NULL, 0, NULL) < 0) { 70.199 - ERR("Couldn't enable shadow mode"); 70.200 + ERROR("Couldn't enable shadow mode"); 70.201 goto out; 70.202 } 70.203 70.204 @@ -740,7 +740,7 @@ int xc_linux_save(int xc_handle, int io_ 70.205 last_iter = 1; 70.206 70.207 if (suspend_and_state(suspend, xc_handle, io_fd, dom, &info, &ctxt)) { 70.208 - ERR("Domain appears not to have suspended"); 70.209 + ERROR("Domain appears not to have suspended"); 70.210 goto out; 70.211 } 70.212 70.213 @@ -761,20 +761,20 @@ int xc_linux_save(int xc_handle, int io_ 70.214 to_skip = malloc(BITMAP_SIZE); 70.215 70.216 if (!to_send || !to_fix || !to_skip) { 70.217 - ERR("Couldn't allocate to_send array"); 70.218 + ERROR("Couldn't allocate to_send array"); 70.219 goto out; 70.220 } 70.221 70.222 memset(to_send, 0xff, BITMAP_SIZE); 70.223 70.224 if (mlock(to_send, BITMAP_SIZE)) { 70.225 - ERR("Unable to mlock to_send"); 70.226 + ERROR("Unable to mlock to_send"); 70.227 return 1; 70.228 } 70.229 70.230 /* (to fix is local only) */ 70.231 if (mlock(to_skip, BITMAP_SIZE)) { 70.232 - ERR("Unable to mlock to_skip"); 70.233 + ERROR("Unable to mlock to_skip"); 70.234 return 1; 70.235 } 70.236 70.237 @@ -785,13 +785,13 @@ int xc_linux_save(int xc_handle, int io_ 70.238 pfn_batch = calloc(MAX_BATCH_SIZE, sizeof(*pfn_batch)); 70.239 70.240 if ((pfn_type == NULL) || (pfn_batch == NULL)) { 70.241 - ERR("failed to alloc memory for pfn_type and/or pfn_batch arrays"); 70.242 + ERROR("failed to alloc memory for pfn_type and/or pfn_batch arrays"); 70.243 errno = ENOMEM; 70.244 goto out; 70.245 } 70.246 70.247 if (mlock(pfn_type, MAX_BATCH_SIZE * sizeof(*pfn_type))) { 70.248 - ERR("Unable to mlock"); 70.249 + ERROR("Unable to mlock"); 70.250 goto out; 70.251 } 70.252 70.253 @@ -817,7 +817,7 @@ int xc_linux_save(int xc_handle, int io_ 70.254 /* Start writing out the saved-domain record. */ 70.255 70.256 if (!write_exact(io_fd, &max_pfn, sizeof(unsigned long))) { 70.257 - ERR("write: max_pfn"); 70.258 + ERROR("write: max_pfn"); 70.259 goto out; 70.260 } 70.261 70.262 @@ -837,13 +837,13 @@ int xc_linux_save(int xc_handle, int io_ 70.263 !write_exact(io_fd, &chunk_sig, 4) || 70.264 !write_exact(io_fd, &chunk_sz, sizeof(chunk_sz)) || 70.265 !write_exact(io_fd, &ctxt, sizeof(ctxt))) { 70.266 - ERR("write: extended info"); 70.267 + ERROR("write: extended info"); 70.268 goto out; 70.269 } 70.270 } 70.271 70.272 if (!write_exact(io_fd, p2m_frame_list, P2M_FL_SIZE)) { 70.273 - ERR("write: p2m_frame_list"); 70.274 + ERROR("write: p2m_frame_list"); 70.275 goto out; 70.276 } 70.277 70.278 @@ -877,7 +877,7 @@ int xc_linux_save(int xc_handle, int io_ 70.279 if (!last_iter && xc_shadow_control( 70.280 xc_handle, dom, XEN_DOMCTL_SHADOW_OP_PEEK, 70.281 to_skip, max_pfn, NULL, 0, NULL) != max_pfn) { 70.282 - ERR("Error peeking shadow bitmap"); 70.283 + ERROR("Error peeking shadow bitmap"); 70.284 goto out; 70.285 } 70.286 70.287 @@ -942,12 +942,12 @@ int xc_linux_save(int xc_handle, int io_ 70.288 70.289 if ((region_base = xc_map_foreign_batch( 70.290 xc_handle, dom, PROT_READ, pfn_type, batch)) == 0) { 70.291 - ERR("map batch failed"); 70.292 + ERROR("map batch failed"); 70.293 goto out; 70.294 } 70.295 70.296 if (xc_get_pfn_type_batch(xc_handle, dom, batch, pfn_type)) { 70.297 - ERR("get_pfn_type_batch failed"); 70.298 + ERROR("get_pfn_type_batch failed"); 70.299 goto out; 70.300 } 70.301 70.302 @@ -978,12 +978,12 @@ int xc_linux_save(int xc_handle, int io_ 70.303 } 70.304 70.305 if(!write_exact(io_fd, &batch, sizeof(unsigned int))) { 70.306 - ERR("Error when writing to state file (2)"); 70.307 + ERROR("Error when writing to state file (2)"); 70.308 goto out; 70.309 } 70.310 70.311 if(!write_exact(io_fd, pfn_type, sizeof(unsigned long)*j)) { 70.312 - ERR("Error when writing to state file (3)"); 70.313 + ERROR("Error when writing to state file (3)"); 70.314 goto out; 70.315 } 70.316 70.317 @@ -1013,7 +1013,7 @@ int xc_linux_save(int xc_handle, int io_ 70.318 goto out; 70.319 70.320 if (ratewrite(io_fd, page, PAGE_SIZE) != PAGE_SIZE) { 70.321 - ERR("Error when writing to state file (4)"); 70.322 + ERROR("Error when writing to state file (4)"); 70.323 goto out; 70.324 } 70.325 70.326 @@ -1021,7 +1021,7 @@ int xc_linux_save(int xc_handle, int io_ 70.327 70.328 /* We have a normal page: just write it directly. */ 70.329 if (ratewrite(io_fd, spage, PAGE_SIZE) != PAGE_SIZE) { 70.330 - ERR("Error when writing to state file (5)"); 70.331 + ERROR("Error when writing to state file (5)"); 70.332 goto out; 70.333 } 70.334 } 70.335 @@ -1056,7 +1056,7 @@ int xc_linux_save(int xc_handle, int io_ 70.336 70.337 /* send "-1" to put receiver into debug mode */ 70.338 if(!write_exact(io_fd, &minusone, sizeof(int))) { 70.339 - ERR("Error when writing to state file (6)"); 70.340 + ERROR("Error when writing to state file (6)"); 70.341 goto out; 70.342 } 70.343 70.344 @@ -1079,7 +1079,7 @@ int xc_linux_save(int xc_handle, int io_ 70.345 70.346 if (suspend_and_state(suspend, xc_handle, io_fd, dom, &info, 70.347 &ctxt)) { 70.348 - ERR("Domain appears not to have suspended"); 70.349 + ERROR("Domain appears not to have suspended"); 70.350 goto out; 70.351 } 70.352 70.353 @@ -1092,7 +1092,7 @@ int xc_linux_save(int xc_handle, int io_ 70.354 if (xc_shadow_control(xc_handle, dom, 70.355 XEN_DOMCTL_SHADOW_OP_CLEAN, to_send, 70.356 max_pfn, NULL, 0, &stats) != max_pfn) { 70.357 - ERR("Error flushing shadow PT"); 70.358 + ERROR("Error flushing shadow PT"); 70.359 goto out; 70.360 } 70.361 70.362 @@ -1110,7 +1110,7 @@ int xc_linux_save(int xc_handle, int io_ 70.363 /* Zero terminate */ 70.364 i = 0; 70.365 if (!write_exact(io_fd, &i, sizeof(int))) { 70.366 - ERR("Error when writing to state file (6)"); 70.367 + ERROR("Error when writing to state file (6)"); 70.368 goto out; 70.369 } 70.370 70.371 @@ -1125,7 +1125,7 @@ int xc_linux_save(int xc_handle, int io_ 70.372 } 70.373 70.374 if(!write_exact(io_fd, &j, sizeof(unsigned int))) { 70.375 - ERR("Error when writing to state file (6a)"); 70.376 + ERROR("Error when writing to state file (6a)"); 70.377 goto out; 70.378 } 70.379 70.380 @@ -1137,7 +1137,7 @@ int xc_linux_save(int xc_handle, int io_ 70.381 i++; 70.382 if (j == 1024 || i == max_pfn) { 70.383 if(!write_exact(io_fd, &pfntab, sizeof(unsigned long)*j)) { 70.384 - ERR("Error when writing to state file (6b)"); 70.385 + ERROR("Error when writing to state file (6b)"); 70.386 goto out; 70.387 } 70.388 j = 0; 70.389 @@ -1148,21 +1148,21 @@ int xc_linux_save(int xc_handle, int io_ 70.390 70.391 /* Canonicalise the suspend-record frame number. */ 70.392 if ( !translate_mfn_to_pfn(&ctxt.user_regs.edx) ){ 70.393 - ERR("Suspend record is not in range of pseudophys map"); 70.394 + ERROR("Suspend record is not in range of pseudophys map"); 70.395 goto out; 70.396 } 70.397 70.398 /* Canonicalise each GDT frame number. */ 70.399 for ( i = 0; i < ctxt.gdt_ents; i += 512 ) { 70.400 if ( !translate_mfn_to_pfn(&ctxt.gdt_frames[i]) ) { 70.401 - ERR("GDT frame is not in range of pseudophys map"); 70.402 + ERROR("GDT frame is not in range of pseudophys map"); 70.403 goto out; 70.404 } 70.405 } 70.406 70.407 /* Canonicalise the page table base pointer. */ 70.408 if ( !MFN_IS_IN_PSEUDOPHYS_MAP(xen_cr3_to_pfn(ctxt.ctrlreg[3])) ) { 70.409 - ERR("PT base is not in range of pseudophys map"); 70.410 + ERROR("PT base is not in range of pseudophys map"); 70.411 goto out; 70.412 } 70.413 ctxt.ctrlreg[3] = 70.414 @@ -1170,7 +1170,7 @@ int xc_linux_save(int xc_handle, int io_ 70.415 70.416 if (!write_exact(io_fd, &ctxt, sizeof(ctxt)) || 70.417 !write_exact(io_fd, live_shinfo, PAGE_SIZE)) { 70.418 - ERR("Error when writing to state file (1)"); 70.419 + ERROR("Error when writing to state file (1)"); 70.420 goto out; 70.421 } 70.422
71.1 --- a/tools/libxc/xc_private.h Sun Oct 22 14:39:15 2006 -0600 71.2 +++ b/tools/libxc/xc_private.h Sun Oct 22 15:23:52 2006 -0600 71.3 @@ -30,6 +30,9 @@ 71.4 #define DECLARE_SYSCTL struct xen_sysctl sysctl 71.5 #endif 71.6 71.7 +#undef PAGE_SHIFT 71.8 +#undef PAGE_SIZE 71.9 +#undef PAGE_MASK 71.10 #define PAGE_SHIFT XC_PAGE_SHIFT 71.11 #define PAGE_SIZE (1UL << PAGE_SHIFT) 71.12 #define PAGE_MASK (~(PAGE_SIZE-1)) 71.13 @@ -56,11 +59,6 @@ 71.14 #define PPRINTF(_f, _a...) 71.15 #endif 71.16 71.17 -#define ERR(_f, _a...) do { \ 71.18 - DPRINTF(_f ": %d\n" , ## _a, errno); \ 71.19 - fflush(stderr); } \ 71.20 -while (0) 71.21 - 71.22 #define ERROR(_m, _a...) \ 71.23 do { \ 71.24 int __saved_errno = errno; \
72.1 --- a/tools/libxc/xc_ptrace.c Sun Oct 22 14:39:15 2006 -0600 72.2 +++ b/tools/libxc/xc_ptrace.c Sun Oct 22 15:23:52 2006 -0600 72.3 @@ -1,5 +1,3 @@ 72.4 -#define XC_PTRACE_PRIVATE 72.5 - 72.6 #include <sys/ptrace.h> 72.7 #include <sys/wait.h> 72.8 #include <time.h>
73.1 --- a/tools/libxc/xc_ptrace.h Sun Oct 22 14:39:15 2006 -0600 73.2 +++ b/tools/libxc/xc_ptrace.h Sun Oct 22 15:23:52 2006 -0600 73.3 @@ -1,9 +1,6 @@ 73.4 #ifndef XC_PTRACE_ 73.5 #define XC_PTRACE_ 73.6 73.7 -#include <thread_db.h> 73.8 - 73.9 -#ifdef XC_PTRACE_PRIVATE 73.10 #define X86_CR0_PE 0x00000001 /* Enable Protected Mode (RW) */ 73.11 #define X86_CR0_PG 0x80000000 /* Paging (RW) */ 73.12 #define BSD_PAGE_MASK (PAGE_SIZE-1) 73.13 @@ -160,25 +157,4 @@ struct gdb_regs { 73.14 } 73.15 #endif 73.16 73.17 -#endif 73.18 - 73.19 -typedef void (*thr_ev_handler_t)(long); 73.20 - 73.21 -void xc_register_event_handler( 73.22 - thr_ev_handler_t h, 73.23 - td_event_e e); 73.24 - 73.25 -long xc_ptrace( 73.26 - int xc_handle, 73.27 - enum __ptrace_request request, 73.28 - uint32_t domid, 73.29 - long addr, 73.30 - long data); 73.31 - 73.32 -int xc_waitdomain( 73.33 - int xc_handle, 73.34 - int domain, 73.35 - int *status, 73.36 - int options); 73.37 - 73.38 #endif /* XC_PTRACE */
74.1 --- a/tools/libxc/xc_ptrace_core.c Sun Oct 22 14:39:15 2006 -0600 74.2 +++ b/tools/libxc/xc_ptrace_core.c Sun Oct 22 15:23:52 2006 -0600 74.3 @@ -1,5 +1,3 @@ 74.4 -#define XC_PTRACE_PRIVATE 74.5 - 74.6 #include <sys/ptrace.h> 74.7 #include <sys/wait.h> 74.8 #include "xc_private.h"
75.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 75.2 +++ b/tools/libxc/xc_solaris.c Sun Oct 22 15:23:52 2006 -0600 75.3 @@ -0,0 +1,235 @@ 75.4 +/****************************************************************************** 75.5 + * 75.6 + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 75.7 + * Use is subject to license terms. 75.8 + * 75.9 + * This program is free software; you can redistribute it and/or 75.10 + * modify it under the terms of the GNU General Public License as 75.11 + * published by the Free Software Foundation, version 2 of the 75.12 + * License. 75.13 + */ 75.14 + 75.15 +#include "xc_private.h" 75.16 + 75.17 +#include <xen/memory.h> 75.18 +#include <xen/sys/evtchn.h> 75.19 +#include <unistd.h> 75.20 +#include <fcntl.h> 75.21 + 75.22 +int xc_interface_open(void) 75.23 +{ 75.24 + int flags, saved_errno; 75.25 + int fd = open("/dev/xen/privcmd", O_RDWR); 75.26 + 75.27 + if ( fd == -1 ) 75.28 + { 75.29 + PERROR("Could not obtain handle on privileged command interface"); 75.30 + return -1; 75.31 + } 75.32 + 75.33 + /* Although we return the file handle as the 'xc handle' the API 75.34 + does not specify / guarentee that this integer is in fact 75.35 + a file handle. Thus we must take responsiblity to ensure 75.36 + it doesn't propagate (ie leak) outside the process */ 75.37 + if ( (flags = fcntl(fd, F_GETFD)) < 0 ) 75.38 + { 75.39 + PERROR("Could not get file handle flags"); 75.40 + goto error; 75.41 + } 75.42 + flags |= FD_CLOEXEC; 75.43 + if ( fcntl(fd, F_SETFD, flags) < 0 ) 75.44 + { 75.45 + PERROR("Could not set file handle flags"); 75.46 + goto error; 75.47 + } 75.48 + 75.49 + return fd; 75.50 + 75.51 + error: 75.52 + saved_errno = errno; 75.53 + close(fd); 75.54 + errno = saved_errno; 75.55 + return -1; 75.56 +} 75.57 + 75.58 +int xc_interface_close(int xc_handle) 75.59 +{ 75.60 + return close(xc_handle); 75.61 +} 75.62 + 75.63 +void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot, 75.64 + xen_pfn_t *arr, int num) 75.65 +{ 75.66 + privcmd_mmapbatch_t ioctlx; 75.67 + void *addr; 75.68 + addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_SHARED, xc_handle, 0); 75.69 + if ( addr == MAP_FAILED ) 75.70 + return NULL; 75.71 + 75.72 + ioctlx.num=num; 75.73 + ioctlx.dom=dom; 75.74 + ioctlx.addr=(unsigned long)addr; 75.75 + ioctlx.arr=arr; 75.76 + if ( ioctl(xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx) < 0 ) 75.77 + { 75.78 + int saved_errno = errno; 75.79 + perror("XXXXXXXX"); 75.80 + (void)munmap(addr, num*PAGE_SIZE); 75.81 + errno = saved_errno; 75.82 + return NULL; 75.83 + } 75.84 + return addr; 75.85 + 75.86 +} 75.87 + 75.88 +void *xc_map_foreign_range(int xc_handle, uint32_t dom, 75.89 + int size, int prot, 75.90 + unsigned long mfn) 75.91 +{ 75.92 + privcmd_mmap_t ioctlx; 75.93 + privcmd_mmap_entry_t entry; 75.94 + void *addr; 75.95 + addr = mmap(NULL, size, prot, MAP_SHARED, xc_handle, 0); 75.96 + if ( addr == MAP_FAILED ) 75.97 + return NULL; 75.98 + 75.99 + ioctlx.num=1; 75.100 + ioctlx.dom=dom; 75.101 + ioctlx.entry=&entry; 75.102 + entry.va=(unsigned long) addr; 75.103 + entry.mfn=mfn; 75.104 + entry.npages=(size+PAGE_SIZE-1)>>PAGE_SHIFT; 75.105 + if ( ioctl(xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx) < 0 ) 75.106 + { 75.107 + int saved_errno = errno; 75.108 + (void)munmap(addr, size); 75.109 + errno = saved_errno; 75.110 + return NULL; 75.111 + } 75.112 + return addr; 75.113 +} 75.114 + 75.115 +int xc_map_foreign_ranges(int xc_handle, uint32_t dom, 75.116 + privcmd_mmap_entry_t *entries, int nr) 75.117 +{ 75.118 + privcmd_mmap_t ioctlx; 75.119 + 75.120 + ioctlx.num = nr; 75.121 + ioctlx.dom = dom; 75.122 + ioctlx.entry = entries; 75.123 + 75.124 + return ioctl(xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx); 75.125 +} 75.126 + 75.127 +static int do_privcmd(int xc_handle, unsigned int cmd, unsigned long data) 75.128 +{ 75.129 + return ioctl(xc_handle, cmd, data); 75.130 +} 75.131 + 75.132 +int do_xen_hypercall(int xc_handle, privcmd_hypercall_t *hypercall) 75.133 +{ 75.134 + return do_privcmd(xc_handle, 75.135 + IOCTL_PRIVCMD_HYPERCALL, 75.136 + (unsigned long)hypercall); 75.137 +} 75.138 + 75.139 +int xc_evtchn_open(void) 75.140 +{ 75.141 + int fd; 75.142 + 75.143 + if ( (fd = open("/dev/xen/evtchn", O_RDWR)) == -1 ) 75.144 + { 75.145 + PERROR("Could not open event channel interface"); 75.146 + return -1; 75.147 + } 75.148 + 75.149 + return fd; 75.150 +} 75.151 + 75.152 +int xc_evtchn_close(int xce_handle) 75.153 +{ 75.154 + return close(xce_handle); 75.155 +} 75.156 + 75.157 +int xc_evtchn_fd(int xce_handle) 75.158 +{ 75.159 + return xce_handle; 75.160 +} 75.161 + 75.162 +int xc_evtchn_notify(int xce_handle, evtchn_port_t port) 75.163 +{ 75.164 + struct ioctl_evtchn_notify notify; 75.165 + 75.166 + notify.port = port; 75.167 + 75.168 + return ioctl(xce_handle, IOCTL_EVTCHN_NOTIFY, ¬ify); 75.169 +} 75.170 + 75.171 +evtchn_port_t xc_evtchn_bind_interdomain(int xce_handle, int domid, 75.172 + evtchn_port_t remote_port) 75.173 +{ 75.174 + struct ioctl_evtchn_bind_interdomain bind; 75.175 + 75.176 + bind.remote_domain = domid; 75.177 + bind.remote_port = remote_port; 75.178 + 75.179 + return ioctl(xce_handle, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind); 75.180 +} 75.181 + 75.182 +int xc_evtchn_unbind(int xce_handle, evtchn_port_t port) 75.183 +{ 75.184 + struct ioctl_evtchn_unbind unbind; 75.185 + 75.186 + unbind.port = port; 75.187 + 75.188 + return ioctl(xce_handle, IOCTL_EVTCHN_UNBIND, &unbind); 75.189 +} 75.190 + 75.191 +evtchn_port_t xc_evtchn_bind_virq(int xce_handle, unsigned int virq) 75.192 +{ 75.193 + struct ioctl_evtchn_bind_virq bind; 75.194 + 75.195 + bind.virq = virq; 75.196 + 75.197 + return ioctl(xce_handle, IOCTL_EVTCHN_BIND_VIRQ, &bind); 75.198 +} 75.199 + 75.200 +static int dorw(int fd, char *data, size_t size, int do_write) 75.201 +{ 75.202 + size_t offset = 0; 75.203 + ssize_t len; 75.204 + 75.205 + while ( offset < size ) 75.206 + { 75.207 + if (do_write) 75.208 + len = write(fd, data + offset, size - offset); 75.209 + else 75.210 + len = read(fd, data + offset, size - offset); 75.211 + 75.212 + if ( len == -1 ) 75.213 + { 75.214 + if ( errno == EINTR ) 75.215 + continue; 75.216 + return -1; 75.217 + } 75.218 + 75.219 + offset += len; 75.220 + } 75.221 + 75.222 + return 0; 75.223 +} 75.224 + 75.225 +evtchn_port_t xc_evtchn_pending(int xce_handle) 75.226 +{ 75.227 + evtchn_port_t port; 75.228 + 75.229 + if ( dorw(xce_handle, (char *)&port, sizeof(port), 0) == -1 ) 75.230 + return -1; 75.231 + 75.232 + return port; 75.233 +} 75.234 + 75.235 +int xc_evtchn_unmask(int xce_handle, evtchn_port_t port) 75.236 +{ 75.237 + return dorw(xce_handle, (char *)&port, sizeof(port), 1); 75.238 +}
76.1 --- a/tools/libxc/xenctrl.h Sun Oct 22 14:39:15 2006 -0600 76.2 +++ b/tools/libxc/xenctrl.h Sun Oct 22 15:23:52 2006 -0600 76.3 @@ -16,7 +16,6 @@ 76.4 76.5 #include <stddef.h> 76.6 #include <stdint.h> 76.7 -#include <sys/ptrace.h> 76.8 #include <xen/xen.h> 76.9 #include <xen/domctl.h> 76.10 #include <xen/sysctl.h> 76.11 @@ -116,18 +115,17 @@ typedef struct xc_core_header { 76.12 76.13 #define XC_CORE_MAGIC 0xF00FEBED 76.14 76.15 -long xc_ptrace_core( 76.16 - int xc_handle, 76.17 - enum __ptrace_request request, 76.18 - uint32_t domid, 76.19 - long addr, 76.20 - long data, 76.21 - vcpu_guest_context_t *ctxt); 76.22 +#ifdef __linux__ 76.23 + 76.24 +#include <sys/ptrace.h> 76.25 +#include <thread_db.h> 76.26 + 76.27 void * map_domain_va_core( 76.28 unsigned long domfd, 76.29 int cpu, 76.30 void *guest_va, 76.31 vcpu_guest_context_t *ctxt); 76.32 + 76.33 int xc_waitdomain_core( 76.34 int xc_handle, 76.35 int domain, 76.36 @@ -135,6 +133,27 @@ int xc_waitdomain_core( 76.37 int options, 76.38 vcpu_guest_context_t *ctxt); 76.39 76.40 +typedef void (*thr_ev_handler_t)(long); 76.41 + 76.42 +void xc_register_event_handler( 76.43 + thr_ev_handler_t h, 76.44 + td_event_e e); 76.45 + 76.46 +long xc_ptrace( 76.47 + int xc_handle, 76.48 + enum __ptrace_request request, 76.49 + uint32_t domid, 76.50 + long addr, 76.51 + long data); 76.52 + 76.53 +int xc_waitdomain( 76.54 + int xc_handle, 76.55 + int domain, 76.56 + int *status, 76.57 + int options); 76.58 + 76.59 +#endif /* __linux__ */ 76.60 + 76.61 /* 76.62 * DOMAIN MANAGEMENT FUNCTIONS 76.63 */
77.1 --- a/tools/libxc/xg_private.c Sun Oct 22 14:39:15 2006 -0600 77.2 +++ b/tools/libxc/xg_private.c Sun Oct 22 15:23:52 2006 -0600 77.3 @@ -7,6 +7,7 @@ 77.4 #include <stdlib.h> 77.5 #include <unistd.h> 77.6 #include <zlib.h> 77.7 +#include <strings.h> 77.8 77.9 #include "xg_private.h" 77.10
78.1 --- a/tools/libxc/xg_private.h Sun Oct 22 14:39:15 2006 -0600 78.2 +++ b/tools/libxc/xg_private.h Sun Oct 22 15:23:52 2006 -0600 78.3 @@ -79,10 +79,6 @@ unsigned long csum_page (void * page); 78.4 #define L4_PAGETABLE_ENTRIES 512 78.5 #endif 78.6 78.7 -#define PAGE_SHIFT XC_PAGE_SHIFT 78.8 -#define PAGE_SIZE (1UL << PAGE_SHIFT) 78.9 -#define PAGE_MASK (~(PAGE_SIZE-1)) 78.10 - 78.11 typedef uint32_t l1_pgentry_32_t; 78.12 typedef uint32_t l2_pgentry_32_t; 78.13 typedef uint64_t l1_pgentry_64_t;
79.1 --- a/tools/misc/Makefile Sun Oct 22 14:39:15 2006 -0600 79.2 +++ b/tools/misc/Makefile Sun Oct 22 15:23:52 2006 -0600 79.3 @@ -1,7 +1,3 @@ 79.4 -INSTALL = install 79.5 -INSTALL_PROG = $(INSTALL) -m0755 79.6 -INSTALL_DIR = $(INSTALL) -d -m0755 79.7 - 79.8 XEN_ROOT=../.. 79.9 include $(XEN_ROOT)/tools/Rules.mk 79.10 79.11 @@ -24,9 +20,6 @@ all: build 79.12 .PHONY: build 79.13 build: $(TARGETS) 79.14 $(MAKE) -C miniterm 79.15 -ifeq ($(CONFIG_MBOOTPACK),y) 79.16 - $(MAKE) -C mbootpack 79.17 -endif 79.18 $(MAKE) -C lomount 79.19 79.20 .PHONY: install 79.21 @@ -38,14 +31,11 @@ install: build 79.22 $(MAKE) -C lomount install 79.23 # No sense in installing miniterm on the Xen box. 79.24 # $(MAKE) -C miniterm install 79.25 -# Likewise mbootpack 79.26 -# $(MAKE) -C mbootpack install 79.27 79.28 .PHONY: clean 79.29 clean: 79.30 $(RM) *.o $(TARGETS) *~ 79.31 $(MAKE) -C miniterm clean 79.32 - $(MAKE) -C mbootpack clean 79.33 $(MAKE) -C lomount clean 79.34 79.35 %.o: %.c $(HDRS) Makefile
80.1 --- a/tools/misc/lomount/Makefile Sun Oct 22 14:39:15 2006 -0600 80.2 +++ b/tools/misc/lomount/Makefile Sun Oct 22 15:23:52 2006 -0600 80.3 @@ -1,8 +1,3 @@ 80.4 -INSTALL = install 80.5 -INSTALL_PROG = $(INSTALL) -m0755 80.6 -INSTALL_DIR = $(INSTALL) -d -m0755 80.7 -INSTALL_DATA = $(INSTALL) -m0644 80.8 - 80.9 XEN_ROOT=../../.. 80.10 include $(XEN_ROOT)/tools/Rules.mk 80.11
81.1 --- a/tools/misc/mbootpack/GPL Sun Oct 22 14:39:15 2006 -0600 81.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 81.3 @@ -1,340 +0,0 @@ 81.4 - GNU GENERAL PUBLIC LICENSE 81.5 - Version 2, June 1991 81.6 - 81.7 - Copyright (C) 1989, 1991 Free Software Foundation, Inc. 81.8 - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 81.9 - Everyone is permitted to copy and distribute verbatim copies 81.10 - of this license document, but changing it is not allowed. 81.11 - 81.12 - Preamble 81.13 - 81.14 - The licenses for most software are designed to take away your 81.15 -freedom to share and change it. By contrast, the GNU General Public 81.16 -License is intended to guarantee your freedom to share and change free 81.17 -software--to make sure the software is free for all its users. This 81.18 -General Public License applies to most of the Free Software 81.19 -Foundation's software and to any other program whose authors commit to 81.20 -using it. (Some other Free Software Foundation software is covered by 81.21 -the GNU Library General Public License instead.) You can apply it to 81.22 -your programs, too. 81.23 - 81.24 - When we speak of free software, we are referring to freedom, not 81.25 -price. Our General Public Licenses are designed to make sure that you 81.26 -have the freedom to distribute copies of free software (and charge for 81.27 -this service if you wish), that you receive source code or can get it 81.28 -if you want it, that you can change the software or use pieces of it 81.29 -in new free programs; and that you know you can do these things. 81.30 - 81.31 - To protect your rights, we need to make restrictions that forbid 81.32 -anyone to deny you these rights or to ask you to surrender the rights. 81.33 -These restrictions translate to certain responsibilities for you if you 81.34 -distribute copies of the software, or if you modify it. 81.35 - 81.36 - For example, if you distribute copies of such a program, whether 81.37 -gratis or for a fee, you must give the recipients all the rights that 81.38 -you have. You must make sure that they, too, receive or can get the 81.39 -source code. And you must show them these terms so they know their 81.40 -rights. 81.41 - 81.42 - We protect your rights with two steps: (1) copyright the software, and 81.43 -(2) offer you this license which gives you legal permission to copy, 81.44 -distribute and/or modify the software. 81.45 - 81.46 - Also, for each author's protection and ours, we want to make certain 81.47 -that everyone understands that there is no warranty for this free 81.48 -software. If the software is modified by someone else and passed on, we 81.49 -want its recipients to know that what they have is not the original, so 81.50 -that any problems introduced by others will not reflect on the original 81.51 -authors' reputations. 81.52 - 81.53 - Finally, any free program is threatened constantly by software 81.54 -patents. We wish to avoid the danger that redistributors of a free 81.55 -program will individually obtain patent licenses, in effect making the 81.56 -program proprietary. To prevent this, we have made it clear that any 81.57 -patent must be licensed for everyone's free use or not licensed at all. 81.58 - 81.59 - The precise terms and conditions for copying, distribution and 81.60 -modification follow. 81.61 - 81.62 - GNU GENERAL PUBLIC LICENSE 81.63 - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 81.64 - 81.65 - 0. This License applies to any program or other work which contains 81.66 -a notice placed by the copyright holder saying it may be distributed 81.67 -under the terms of this General Public License. The "Program", below, 81.68 -refers to any such program or work, and a "work based on the Program" 81.69 -means either the Program or any derivative work under copyright law: 81.70 -that is to say, a work containing the Program or a portion of it, 81.71 -either verbatim or with modifications and/or translated into another 81.72 -language. (Hereinafter, translation is included without limitation in 81.73 -the term "modification".) Each licensee is addressed as "you". 81.74 - 81.75 -Activities other than copying, distribution and modification are not 81.76 -covered by this License; they are outside its scope. The act of 81.77 -running the Program is not restricted, and the output from the Program 81.78 -is covered only if its contents constitute a work based on the 81.79 -Program (independent of having been made by running the Program). 81.80 -Whether that is true depends on what the Program does. 81.81 - 81.82 - 1. You may copy and distribute verbatim copies of the Program's 81.83 -source code as you receive it, in any medium, provided that you 81.84 -conspicuously and appropriately publish on each copy an appropriate 81.85 -copyright notice and disclaimer of warranty; keep intact all the 81.86 -notices that refer to this License and to the absence of any warranty; 81.87 -and give any other recipients of the Program a copy of this License 81.88 -along with the Program. 81.89 - 81.90 -You may charge a fee for the physical act of transferring a copy, and 81.91 -you may at your option offer warranty protection in exchange for a fee. 81.92 - 81.93 - 2. You may modify your copy or copies of the Program or any portion 81.94 -of it, thus forming a work based on the Program, and copy and 81.95 -distribute such modifications or work under the terms of Section 1 81.96 -above, provided that you also meet all of these conditions: 81.97 - 81.98 - a) You must cause the modified files to carry prominent notices 81.99 - stating that you changed the files and the date of any change. 81.100 - 81.101 - b) You must cause any work that you distribute or publish, that in 81.102 - whole or in part contains or is derived from the Program or any 81.103 - part thereof, to be licensed as a whole at no charge to all third 81.104 - parties under the terms of this License. 81.105 - 81.106 - c) If the modified program normally reads commands interactively 81.107 - when run, you must cause it, when started running for such 81.108 - interactive use in the most ordinary way, to print or display an 81.109 - announcement including an appropriate copyright notice and a 81.110 - notice that there is no warranty (or else, saying that you provide 81.111 - a warranty) and that users may redistribute the program under 81.112 - these conditions, and telling the user how to view a copy of this 81.113 - License. (Exception: if the Program itself is interactive but 81.114 - does not normally print such an announcement, your work based on 81.115 - the Program is not required to print an announcement.) 81.116 - 81.117 -These requirements apply to the modified work as a whole. If 81.118 -identifiable sections of that work are not derived from the Program, 81.119 -and can be reasonably considered independent and separate works in 81.120 -themselves, then this License, and its terms, do not apply to those 81.121 -sections when you distribute them as separate works. But when you 81.122 -distribute the same sections as part of a whole which is a work based 81.123 -on the Program, the distribution of the whole must be on the terms of 81.124 -this License, whose permissions for other licensees extend to the 81.125 -entire whole, and thus to each and every part regardless of who wrote it. 81.126 - 81.127 -Thus, it is not the intent of this section to claim rights or contest 81.128 -your rights to work written entirely by you; rather, the intent is to 81.129 -exercise the right to control the distribution of derivative or 81.130 -collective works based on the Program. 81.131 - 81.132 -In addition, mere aggregation of another work not based on the Program 81.133 -with the Program (or with a work based on the Program) on a volume of 81.134 -a storage or distribution medium does not bring the other work under 81.135 -the scope of this License. 81.136 - 81.137 - 3. You may copy and distribute the Program (or a work based on it, 81.138 -under Section 2) in object code or executable form under the terms of 81.139 -Sections 1 and 2 above provided that you also do one of the following: 81.140 - 81.141 - a) Accompany it with the complete corresponding machine-readable 81.142 - source code, which must be distributed under the terms of Sections 81.143 - 1 and 2 above on a medium customarily used for software interchange; or, 81.144 - 81.145 - b) Accompany it with a written offer, valid for at least three 81.146 - years, to give any third party, for a charge no more than your 81.147 - cost of physically performing source distribution, a complete 81.148 - machine-readable copy of the corresponding source code, to be 81.149 - distributed under the terms of Sections 1 and 2 above on a medium 81.150 - customarily used for software interchange; or, 81.151 - 81.152 - c) Accompany it with the information you received as to the offer 81.153 - to distribute corresponding source code. (This alternative is 81.154 - allowed only for noncommercial distribution and only if you 81.155 - received the program in object code or executable form with such 81.156 - an offer, in accord with Subsection b above.) 81.157 - 81.158 -The source code for a work means the preferred form of the work for 81.159 -making modifications to it. For an executable work, complete source 81.160 -code means all the source code for all modules it contains, plus any 81.161 -associated interface definition files, plus the scripts used to 81.162 -control compilation and installation of the executable. However, as a 81.163 -special exception, the source code distributed need not include 81.164 -anything that is normally distributed (in either source or binary 81.165 -form) with the major components (compiler, kernel, and so on) of the 81.166 -operating system on which the executable runs, unless that component 81.167 -itself accompanies the executable. 81.168 - 81.169 -If distribution of executable or object code is made by offering 81.170 -access to copy from a designated place, then offering equivalent 81.171 -access to copy the source code from the same place counts as 81.172 -distribution of the source code, even though third parties are not 81.173 -compelled to copy the source along with the object code. 81.174 - 81.175 - 4. You may not copy, modify, sublicense, or distribute the Program 81.176 -except as expressly provided under this License. Any attempt 81.177 -otherwise to copy, modify, sublicense or distribute the Program is 81.178 -void, and will automatically terminate your rights under this License. 81.179 -However, parties who have received copies, or rights, from you under 81.180 -this License will not have their licenses terminated so long as such 81.181 -parties remain in full compliance. 81.182 - 81.183 - 5. You are not required to accept this License, since you have not 81.184 -signed it. However, nothing else grants you permission to modify or 81.185 -distribute the Program or its derivative works. These actions are 81.186 -prohibited by law if you do not accept this License. Therefore, by 81.187 -modifying or distributing the Program (or any work based on the 81.188 -Program), you indicate your acceptance of this License to do so, and 81.189 -all its terms and conditions for copying, distributing or modifying 81.190 -the Program or works based on it. 81.191 - 81.192 - 6. Each time you redistribute the Program (or any work based on the 81.193 -Program), the recipient automatically receives a license from the 81.194 -original licensor to copy, distribute or modify the Program subject to 81.195 -these terms and conditions. You may not impose any further 81.196 -restrictions on the recipients' exercise of the rights granted herein. 81.197 -You are not responsible for enforcing compliance by third parties to 81.198 -this License. 81.199 - 81.200 - 7. If, as a consequence of a court judgment or allegation of patent 81.201 -infringement or for any other reason (not limited to patent issues), 81.202 -conditions are imposed on you (whether by court order, agreement or 81.203 -otherwise) that contradict the conditions of this License, they do not 81.204 -excuse you from the conditions of this License. If you cannot 81.205 -distribute so as to satisfy simultaneously your obligations under this 81.206 -License and any other pertinent obligations, then as a consequence you 81.207 -may not distribute the Program at all. For example, if a patent 81.208 -license would not permit royalty-free redistribution of the Program by 81.209 -all those who receive copies directly or indirectly through you, then 81.210 -the only way you could satisfy both it and this License would be to 81.211 -refrain entirely from distribution of the Program. 81.212 - 81.213 -If any portion of this section is held invalid or unenforceable under 81.214 -any particular circumstance, the balance of the section is intended to 81.215 -apply and the section as a whole is intended to apply in other 81.216 -circumstances. 81.217 - 81.218 -It is not the purpose of this section to induce you to infringe any 81.219 -patents or other property right claims or to contest validity of any 81.220 -such claims; this section has the sole purpose of protecting the 81.221 -integrity of the free software distribution system, which is 81.222 -implemented by public license practices. Many people have made 81.223 -generous contributions to the wide range of software distributed 81.224 -through that system in reliance on consistent application of that 81.225 -system; it is up to the author/donor to decide if he or she is willing 81.226 -to distribute software through any other system and a licensee cannot 81.227 -impose that choice. 81.228 - 81.229 -This section is intended to make thoroughly clear what is believed to 81.230 -be a consequence of the rest of this License. 81.231 - 81.232 - 8. If the distribution and/or use of the Program is restricted in 81.233 -certain countries either by patents or by copyrighted interfaces, the 81.234 -original copyright holder who places the Program under this License 81.235 -may add an explicit geographical distribution limitation excluding 81.236 -those countries, so that distribution is permitted only in or among 81.237 -countries not thus excluded. In such case, this License incorporates 81.238 -the limitation as if written in the body of this License. 81.239 - 81.240 - 9. The Free Software Foundation may publish revised and/or new versions 81.241 -of the General Public License from time to time. Such new versions will 81.242 -be similar in spirit to the present version, but may differ in detail to 81.243 -address new problems or concerns. 81.244 - 81.245 -Each version is given a distinguishing version number. If the Program 81.246 -specifies a version number of this License which applies to it and "any 81.247 -later version", you have the option of following the terms and conditions 81.248 -either of that version or of any later version published by the Free 81.249 -Software Foundation. If the Program does not specify a version number of 81.250 -this License, you may choose any version ever published by the Free Software 81.251 -Foundation. 81.252 - 81.253 - 10. If you wish to incorporate parts of the Program into other free 81.254 -programs whose distribution conditions are different, write to the author 81.255 -to ask for permission. For software which is copyrighted by the Free 81.256 -Software Foundation, write to the Free Software Foundation; we sometimes 81.257 -make exceptions for this. Our decision will be guided by the two goals 81.258 -of preserving the free status of all derivatives of our free software and 81.259 -of promoting the sharing and reuse of software generally. 81.260 - 81.261 - NO WARRANTY 81.262 - 81.263 - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 81.264 -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 81.265 -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 81.266 -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 81.267 -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 81.268 -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 81.269 -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 81.270 -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 81.271 -REPAIR OR CORRECTION. 81.272 - 81.273 - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 81.274 -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 81.275 -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 81.276 -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 81.277 -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 81.278 -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 81.279 -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 81.280 -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 81.281 -POSSIBILITY OF SUCH DAMAGES. 81.282 - 81.283 - END OF TERMS AND CONDITIONS 81.284 - 81.285 - How to Apply These Terms to Your New Programs 81.286 - 81.287 - If you develop a new program, and you want it to be of the greatest 81.288 -possible use to the public, the best way to achieve this is to make it 81.289 -free software which everyone can redistribute and change under these terms. 81.290 - 81.291 - To do so, attach the following notices to the program. It is safest 81.292 -to attach them to the start of each source file to most effectively 81.293 -convey the exclusion of warranty; and each file should have at least 81.294 -the "copyright" line and a pointer to where the full notice is found. 81.295 - 81.296 - <one line to give the program's name and a brief idea of what it does.> 81.297 - Copyright (C) <year> <name of author> 81.298 - 81.299 - This program is free software; you can redistribute it and/or modify 81.300 - it under the terms of the GNU General Public License as published by 81.301 - the Free Software Foundation; either version 2 of the License, or 81.302 - (at your option) any later version. 81.303 - 81.304 - This program is distributed in the hope that it will be useful, 81.305 - but WITHOUT ANY WARRANTY; without even the implied warranty of 81.306 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 81.307 - GNU General Public License for more details. 81.308 - 81.309 - You should have received a copy of the GNU General Public License 81.310 - along with this program; if not, write to the Free Software 81.311 - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 81.312 - 81.313 - 81.314 -Also add information on how to contact you by electronic and paper mail. 81.315 - 81.316 -If the program is interactive, make it output a short notice like this 81.317 -when it starts in an interactive mode: 81.318 - 81.319 - Gnomovision version 69, Copyright (C) year name of author 81.320 - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 81.321 - This is free software, and you are welcome to redistribute it 81.322 - under certain conditions; type `show c' for details. 81.323 - 81.324 -The hypothetical commands `show w' and `show c' should show the appropriate 81.325 -parts of the General Public License. Of course, the commands you use may 81.326 -be called something other than `show w' and `show c'; they could even be 81.327 -mouse-clicks or menu items--whatever suits your program. 81.328 - 81.329 -You should also get your employer (if you work as a programmer) or your 81.330 -school, if any, to sign a "copyright disclaimer" for the program, if 81.331 -necessary. Here is a sample; alter the names: 81.332 - 81.333 - Yoyodyne, Inc., hereby disclaims all copyright interest in the program 81.334 - `Gnomovision' (which makes passes at compilers) written by James Hacker. 81.335 - 81.336 - <signature of Ty Coon>, 1 April 1989 81.337 - Ty Coon, President of Vice 81.338 - 81.339 -This General Public License does not permit incorporating your program into 81.340 -proprietary programs. If your program is a subroutine library, you may 81.341 -consider it more useful to permit linking proprietary applications with the 81.342 -library. If this is what you want to do, use the GNU Library General 81.343 -Public License instead of this License.
82.1 --- a/tools/misc/mbootpack/Makefile Sun Oct 22 14:39:15 2006 -0600 82.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 82.3 @@ -1,68 +0,0 @@ 82.4 -# 82.5 -# Makefile for mbootpack 82.6 -# 82.7 -INSTALL = install 82.8 -INSTALL_PROG = $(INSTALL) -m0755 82.9 -INSTALL_DIR = $(INSTALL) -d -m0755 82.10 - 82.11 -XEN_ROOT=../../.. 82.12 -include $(XEN_ROOT)/tools/Rules.mk 82.13 - 82.14 -.PHONY: all 82.15 -all: build 82.16 - 82.17 -.PHONY: build 82.18 -build: mbootpack 82.19 - 82.20 -.PHONY: install 82.21 -install: build 82.22 - $(INSTALL_PROG) mbootpack $(DESTDIR)/usr/bin 82.23 - 82.24 -# Tools etc. 82.25 -RM := rm -f 82.26 -INCS := -I. -I- 82.27 -DEFS := 82.28 - 82.29 -# What object files need building for the program 82.30 -OBJS := mbootpack.o buildimage.o 82.31 - 82.32 -# Get gcc to generate the dependencies for us. 82.33 -DEPFLAGS = -Wp,-MD,.$(@F).d 82.34 -DEPS = .*.d 82.35 - 82.36 -mbootpack: $(OBJS) 82.37 - $(HOSTCC) $(HOSTCFLAGS) -o $@ $(filter-out %.a, $^) 82.38 - 82.39 -.PHONY: clean 82.40 -clean: 82.41 - $(RM) mbootpack *.o $(DEPS) bootsect setup bzimage_header.c bin2c 82.42 - 82.43 -bootsect: bootsect.S 82.44 - $(CC) -m32 $(INCS) $(DEFS) -D__MB_ASM -c bootsect.S -o bootsect.o 82.45 - $(LD) -m elf_i386 -Ttext 0x0 -s --oformat binary bootsect.o -o $@ 82.46 - 82.47 -setup: setup.S 82.48 - $(CC) -m32 $(INCS) $(DEFS) -D__MB_ASM -c setup.S -o setup.o 82.49 - $(LD) -m elf_i386 -Ttext 0x0 -s --oformat binary setup.o -o $@ 82.50 - 82.51 -bin2c: bin2c.o 82.52 - $(HOSTCC) $(HOSTCFLAGS) -o $@ $^ 82.53 - 82.54 -bzimage_header.c: bootsect setup bin2c 82.55 - ./bin2c -n 8 -b1 -a bzimage_bootsect bootsect > bzimage_header.c 82.56 - ./bin2c -n 8 -b1 -a bzimage_setup setup >> bzimage_header.c 82.57 - 82.58 -buildimage.c: bzimage_header.c 82.59 - @ 82.60 - 82.61 -%.o: %.c 82.62 - $(HOSTCC) $(DEPFLAGS) $(HOSTCFLAGS) $(INCS) $(DEFS) -c $< -o $@ 82.63 - 82.64 -.PRECIOUS: $(OBJS) $(OBJS:.o=.c) $(DEPS) 82.65 -.SUFFIXES: 82.66 - 82.67 --include $(DEPS) 82.68 - 82.69 -# 82.70 -# EOF 82.71 -#
83.1 --- a/tools/misc/mbootpack/README Sun Oct 22 14:39:15 2006 -0600 83.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 83.3 @@ -1,77 +0,0 @@ 83.4 - 83.5 -mbootpack 83.6 ---------- 83.7 - 83.8 -This is a utility to take a multiboot kernel and modules and repackage 83.9 -them in a form that a standard linux bootloader will be able to load them. 83.10 -It statically allocates memory addresses based on a 'standard' PC memory 83.11 -layout, and then saves the image of the loaded system, along with an 83.12 -almost-standard linux bzImage header which takes care of the start-of-day 83.13 -requirements of a multiboot kernel (setting up 32-bit protected mode, etc.) 83.14 - 83.15 -Example invocation, to package a xen VMM and xenlinux guest and initrd: 83.16 - 83.17 - mbootpack -o bzImage -m ./xenlinux -m ./initrd.img ./xen-image 83.18 - 83.19 -You can now boot the 'bzImage' file using your favourite linux bootloader. 83.20 - 83.21 -The kernel command line will be provided at boot time by the bootloader 83.22 -(you can specify a kernel command-line using the '-c' flag, but it will 83.23 -be overridden at boot time unledd the bootloder provides an entirely 83.24 -empty command line). If you wan to override the command line for the 83.25 -first module (i.e. domain 0 kernel in Xen) at boot time, append ' -- ' 83.26 -and the module commadn line to the bootloader command line, e.g.: 83.27 - 83.28 - boot: bzImage com1=9600,8n1 console=com1 dom0_mem=49152 -- root=/dev/sda3 ro console=ttyS0,9600n8 83.29 - 83.30 -Everything before the '--' is passed to the kernel (xen) as its command 83.31 -line; everything after is passed to the first module (xenlinux). 83.32 - 83.33 -This is ALPHA code: there are execution paths which have *not* been 83.34 -tested, though it works for loading the Xen hypervisor using GrUB, LILO 83.35 -or SYSLINUX. Bug reports and patches are very welcome. 83.36 - 83.37 -Possible features for future versions (all look possible, if there's any 83.38 -demand for them): 83.39 - 83.40 - - support for kernels that load below 1MB 83.41 - - zImage-style compressed images 83.42 - - sane error messgaes for insane load addresses 83.43 - - support for the MULTIBOOT_VIDEO_MODE bit 83.44 - - proper support for passing E820h memory-maps from bzImage 83.45 - 83.46 - 83.47 -Tim Deegan <tjd21@cl.cam.ac.uk>, March 2005 83.48 - 83.49 - 83.50 - 83.51 -License and attributions 83.52 ------------------------- 83.53 - 83.54 -The bzImage header block was originally taken from the Linux kernel. 83.55 -http://www.kernel.org/ 83.56 - 83.57 -Some parts of the Multiboot loader code are based on GNU GRUB. 83.58 -mb_info.h and mb_header.h are taken from GNU GRUB. 83.59 -http://www.gnu.org/software/grub/ 83.60 - 83.61 -Bin2C was written by Nicolas Doualot; I tidied it a bit for a clean compile. 83.62 -http://slubman.celeonet.fr/program.php?style=Default&project=bin2c 83.63 - 83.64 -All other code is copyright (C) 2003-2005 Tim Deegan (tjd21@cl.cam.ac.uk) 83.65 - 83.66 -mbootpack is distributed under the GNU General Public License: see "GPL" 83.67 - 83.68 -This program is free software; you can redistribute it and/or modify 83.69 -it under the terms of the GNU General Public License as published by 83.70 -the Free Software Foundation; either version 2 of the License, or 83.71 -(at your option) any later version. 83.72 - 83.73 -This program is distributed in the hope that it will be useful, 83.74 -but WITHOUT ANY WARRANTY; without even the implied warranty of 83.75 -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 83.76 -GNU General Public License for more details. 83.77 - 83.78 -You should have received a copy of the GNU General Public License 83.79 -along with this program; if not, write to the Free Software 83.80 -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
84.1 --- a/tools/misc/mbootpack/bin2c.c Sun Oct 22 14:39:15 2006 -0600 84.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 84.3 @@ -1,356 +0,0 @@ 84.4 -/*************************************************************************************** 84.5 - Project informations: 84.6 - Project: bin2c 84.7 - Version: 1.00 84.8 - Plateforme: PC 84.9 - Copyright: DNDD.INC 84.10 - Date: 28/03/2004 84.11 - 84.12 - File informations: 84.13 - Name: bin2c.c 84.14 - Description:Convert any file to a C array 84.15 - 84.16 - Author informations: 84.17 - Author: DOUALOT Nicolas 84.18 - E-Mail: slubman@laposte.net 84.19 - site: http://membres.lycos.fr/slubman/gp32 84.20 -***************************************************************************************/ 84.21 - 84.22 - 84.23 -#include <stdio.h> /*perror */ 84.24 -#include <sys/mman.h> /*PROT_READ,MAP_xxx */ 84.25 -#include <fcntl.h> /*O_RDONLY */ 84.26 -#include <sys/stat.h> /*stat */ 84.27 -#include <stdlib.h> /*atoi */ 84.28 -#include <string.h> /*strcmp */ 84.29 -#include <ctype.h> /*toupper */ 84.30 - 84.31 -#define VERSION "1.10" 84.32 - 84.33 - 84.34 -static void help(void) 84.35 -{ 84.36 - fprintf(stdout, "\nbin2c v"VERSION"\n"); 84.37 - fprintf(stdout, "Slubman DevSoft (c)2003-2004 slubman.dndd@laposte.net \n\n"); 84.38 - 84.39 - fprintf(stdout, "Usage: bin2c [flags] <infile>\n\n"); 84.40 - 84.41 - //fprintf(stdout, "\t-quiet :\tdon't output standard messages\n"); 84.42 - //fprintf(stdout, "\t-slash :\tappend backslash at end of line\n"); 84.43 - fprintf(stdout, "\t-n <count> :\tnumber of items per line\n"); 84.44 - fprintf(stdout, "\t-b1 :\tgenerate unsigned char array\n"); 84.45 - fprintf(stdout, "\t-b2 :\tgenerate unsigned short array\n"); 84.46 - fprintf(stdout, "\t-b4 :\tgenerate unsigned long array\n"); 84.47 - fprintf(stdout, "\t-a <name> :\tgenerate an array with given name\n"); 84.48 - fprintf(stdout, "\t-ss <nr> :\tskip number of bytes at begin of inputfile\n"); 84.49 - fprintf(stdout, "\t-se <nr> :\tskip number of bytes at end of inputfile\n"); 84.50 - fprintf(stdout, "\t-lb <nr> :\tinsert an additionally linebreak every nr line\n"); 84.51 - fprintf(stdout, "\t-h :\tproduce an header\n"); 84.52 - fprintf(stdout, "\tinfile :\tname of infile\n"); 84.53 - fprintf(stdout, "\toutfile :\tname of outfile (use \"-\" for stdout)\n\n"); 84.54 - 84.55 - fprintf(stdout, " \tconverts binary file to C array data\n"); 84.56 -} 84.57 - 84.58 -static void UnknownFlag(char *flag) 84.59 -{ 84.60 - fprintf(stderr, "Error: unknown flag %s\n", flag); 84.61 - help(); 84.62 - exit(EXIT_FAILURE); 84.63 -} 84.64 - 84.65 -static void WriteHeader(FILE * outFile, char *oFileName, char *iFileName) 84.66 -{ 84.67 - // File Header 84.68 - fprintf(outFile, "/***************************************************************************************\n"); 84.69 - fprintf(outFile, "* File Name:\n"); 84.70 - fprintf(outFile, "* Name: %s\n", oFileName); 84.71 - fprintf(outFile, "* From: %s\n", iFileName); 84.72 - fprintf(outFile, "* Created by :bin2c v"VERSION"\n*\n"); 84.73 - fprintf(outFile, "* bin2c v"VERSION":\n"); 84.74 - fprintf(outFile, "* Author: DOUALOT Nicolas\n"); 84.75 - fprintf(outFile, "* E-Mail: slubman.dndd@laposte.net\n"); 84.76 - fprintf(outFile, "* site: http://www.slubman.linux-fan.com/\n"); 84.77 - fprintf(outFile, "***************************************************************************************/\n\n"); 84.78 -} 84.79 - 84.80 -int main(int argc, char *argv[]) 84.81 -{ 84.82 - FILE *inFile = stdin, *outFile = stdout; 84.83 - int a, i, nbLine = 0; 84.84 - unsigned char *memory; 84.85 - struct stat st; 84.86 - 84.87 - // Options 84.88 - char arrayName[255] = "array"; // Array name 84.89 - char *iFileName = NULL; // File to convert 84.90 - char *oFileName = NULL; // File to write 84.91 - int bpd = 1; // Array item length 84.92 - int lb = 0; // Array blank line each lb line(s) 84.93 - int nbCol = 15; // Nuber of items per line 84.94 - int SkeepStart = 0; // Number of byte to skip at file begining 84.95 - int SkeepEnd = 0; // Number of byte to skip at file end 84.96 - int header = 0; // Produce an header 84.97 - 84.98 - // Is there the good number of arguments 84.99 - if (argc < 2) 84.100 - { 84.101 - help(); 84.102 - return 0; 84.103 - } 84.104 - 84.105 - // On récupère les arguments (Ready for more options) 84.106 - for (a = 1; a < argc; a++) 84.107 - { 84.108 - // An option 84.109 - if (argv[a][0] == '-') 84.110 - { 84.111 - // Wich flag is it ? 84.112 - switch (argv[a][1]) 84.113 - { 84.114 - // Writting on stdout 84.115 - case 0: 84.116 - printf("%s\n", argv[a]); 84.117 - outFile = stdout; 84.118 - break; 84.119 - 84.120 - // ArrayName flag 84.121 - case 'a': 84.122 - strcpy(arrayName, argv[++a]); 84.123 - break; 84.124 - 84.125 - // Data type 84.126 - case 'b': 84.127 - switch (argv[a][2]) 84.128 - { 84.129 - case '1': 84.130 - bpd = 1; 84.131 - break; 84.132 - 84.133 - case '2': 84.134 - bpd = 2; 84.135 - break; 84.136 - 84.137 - case '4': 84.138 - bpd = 4; 84.139 - break; 84.140 - 84.141 - default: 84.142 - UnknownFlag(argv[a]); 84.143 - } 84.144 - break; 84.145 - 84.146 - // Produce an header 84.147 - case 'h': 84.148 - header = 1; 84.149 - break; 84.150 - 84.151 - // New line each n line 84.152 - case 'l': 84.153 - switch (argv[a][2]) 84.154 - { 84.155 - case 'b': 84.156 - lb = atoi(argv[++a]); 84.157 - break; 84.158 - 84.159 - default: 84.160 - UnknownFlag(argv[a]); 84.161 - } 84.162 - 84.163 - // Number of bit per line 84.164 - case 'n': 84.165 - nbCol = atoi(argv[++a]); 84.166 - break; 84.167 - 84.168 - // Skip bytes 84.169 - case 's': 84.170 - switch (argv[a][2]) 84.171 - { 84.172 - // Beginig of file 84.173 - case 's': 84.174 - SkeepStart = atoi(argv[++a]); 84.175 - break; 84.176 - 84.177 - // End of file 84.178 - case 'e': 84.179 - SkeepEnd = atoi(argv[++a]); 84.180 - break; 84.181 - 84.182 - // Flag inconnu 84.183 - default: 84.184 - UnknownFlag(argv[a]); 84.185 - } 84.186 - 84.187 - // Flag inconnu 84.188 - default: 84.189 - UnknownFlag(argv[a]); 84.190 - } 84.191 - } 84.192 - // A filename 84.193 - else 84.194 - { 84.195 - if (iFileName == NULL) 84.196 - { 84.197 - iFileName = argv[a]; 84.198 - if ((inFile = fopen(iFileName, "rb")) == NULL) 84.199 - { 84.200 - fprintf(stderr, "Error: can't open %s\n", iFileName); 84.201 - exit(EXIT_FAILURE); 84.202 - } 84.203 - } 84.204 - else 84.205 - { 84.206 - if (oFileName == NULL) 84.207 - { 84.208 - oFileName = argv[a]; 84.209 - if ((outFile = fopen(oFileName, "wb")) == NULL) 84.210 - { 84.211 - fprintf(stderr, "Error: can't open %s\n", oFileName); 84.212 - exit(EXIT_FAILURE); 84.213 - } 84.214 - } 84.215 - else 84.216 - { 84.217 - fprintf(stderr, "Error: Too many filesnames given!\n"); 84.218 - help(); 84.219 - exit(EXIT_FAILURE); 84.220 - } 84.221 - } 84.222 - } 84.223 - } 84.224 - 84.225 - if (!iFileName) 84.226 - exit(EXIT_FAILURE); 84.227 - 84.228 - // Get file informations 84.229 - if (stat(iFileName, &st) != 0) 84.230 - { 84.231 - fprintf(stderr, "Error: when scanning file %s\n", argv[1]); 84.232 - exit(EXIT_FAILURE); 84.233 - } 84.234 - 84.235 - // Allocating memory 84.236 - if (!(memory = malloc(st.st_size + 3))) 84.237 - { 84.238 - memset(memory, 0, st.st_size + 3); 84.239 - fprintf(stderr, "Error: not enought memory\n"); 84.240 - exit(EXIT_FAILURE); 84.241 - } 84.242 - 84.243 - // Reading the file 84.244 - if (fread(memory, 1, st.st_size, inFile) != (size_t)st.st_size) 84.245 - { 84.246 - fprintf(stderr, "Error: when reading file %s\n", argv[1]); 84.247 - fclose(inFile); 84.248 - exit(EXIT_FAILURE); 84.249 - } 84.250 - fclose(inFile); 84.251 - 84.252 - // Must produce an header 84.253 - if (header) 84.254 - { 84.255 - unsigned int i; 84.256 - char hFileName[256], *def = NULL; 84.257 - FILE *hFile = stdout; 84.258 - 84.259 - if (oFileName) 84.260 - { 84.261 - strcpy(hFileName, oFileName); 84.262 - hFileName[strlen(hFileName) - 1] = 'h'; 84.263 - hFile = fopen(hFileName, "wt"); 84.264 - } 84.265 - 84.266 - WriteHeader(hFile, hFileName, iFileName); 84.267 - 84.268 - // Replace all '.' by '_' 84.269 - for (i = 0; i < strlen(hFileName); i++) 84.270 - if (hFileName[i] == '.') 84.271 - hFileName[i] = '_'; 84.272 - else 84.273 - hFileName[i] = toupper(hFileName[i]); 84.274 - 84.275 - // the #ifdef at the begining 84.276 - def = strrchr(hFileName, '/'); 84.277 - def = def ? def + 1 : hFileName; 84.278 - fprintf(hFile, "#ifndef __%s__\n#define __%s__\n\n", def, def); 84.279 - 84.280 - // Define array size 84.281 - fprintf(hFile, "#define _%s_size_ %u\n\n", arrayName, (unsigned int) (st.st_size - SkeepStart - SkeepEnd) / bpd); 84.282 - 84.283 - // Begin the array 84.284 - fprintf(hFile, "extern unsigned "); 84.285 - fprintf(hFile, "%s ", bpd == 1 ? "char" : bpd == 2 ? "short" : "long"); 84.286 - fprintf(hFile, "%s[", arrayName); 84.287 - fprintf(hFile, "%u];\n\n", (unsigned int) (st.st_size - SkeepStart - SkeepEnd) / bpd); 84.288 - 84.289 - // the #endif at the end 84.290 - fprintf(hFile, "#endif\n\n"); 84.291 - 84.292 - if (oFileName) 84.293 - fclose(hFile); 84.294 - } 84.295 - 84.296 - WriteHeader(outFile, oFileName, iFileName); 84.297 - 84.298 - // Define array size 84.299 - if (!header) 84.300 - fprintf(outFile, "#define _%s_size_ %u\n\n", arrayName, (unsigned int) (st.st_size - SkeepStart - SkeepEnd) / bpd); 84.301 - 84.302 - // Begin the array 84.303 - fprintf(outFile, "unsigned "); 84.304 - fprintf(outFile, "%s ", bpd == 1 ? "char" : bpd == 2 ? "short" : "long"); 84.305 - fprintf(outFile, "%s[", arrayName); 84.306 - fprintf(outFile, "%u] = {\n\t", (unsigned int) (st.st_size - SkeepStart - SkeepEnd) / bpd); 84.307 - 84.308 - // Writing file elements 84.309 - for (i = 0; i < (st.st_size - SkeepEnd - SkeepStart) / bpd; /*i+=bpd */ i++) 84.310 - { 84.311 - // We write an item of bpd byte(s) 84.312 - switch (bpd) 84.313 - { 84.314 - case 1: 84.315 - fprintf(outFile, "0x%02x", *(unsigned char *) &memory[SkeepStart + i]); 84.316 - break; 84.317 - 84.318 - case 2: 84.319 - fprintf(outFile, "0x%04x", *(unsigned short *) &memory[SkeepStart + i]); 84.320 - break; 84.321 - 84.322 - case 4: 84.323 - fprintf(outFile, "0x%08lx", *(unsigned long *) &memory[SkeepStart + i]); 84.324 - break; 84.325 - } 84.326 - 84.327 - // Must put a coma ? 84.328 - if (i != st.st_size - 1) 84.329 - fprintf(outFile, ","); 84.330 - 84.331 - // End of a line ? 84.332 - if (i && !((i + 1) % nbCol)) 84.333 - { 84.334 - // -lb option 84.335 - if (lb && !((++nbLine) % lb)) 84.336 - fprintf(outFile, "\n"); 84.337 - fprintf(outFile, "\n\t"); 84.338 - } 84.339 - // Add a space 84.340 - else 84.341 - fprintf(outFile, " "); 84.342 - } 84.343 - 84.344 - // The last line as nbCol elements 84.345 - if (((st.st_size - SkeepStart - SkeepEnd) / bpd) % nbCol) 84.346 - fprintf(outFile, "\n"); 84.347 - 84.348 - // Close the array 84.349 - fprintf(outFile, "};\n"); 84.350 - 84.351 - // CLose the output file 84.352 - if (outFile != stdout) 84.353 - fclose(outFile); 84.354 - 84.355 - // Free allocated memory 84.356 - free(memory); 84.357 - 84.358 - exit(EXIT_SUCCESS); 84.359 -}
85.1 --- a/tools/misc/mbootpack/bootsect.S Sun Oct 22 14:39:15 2006 -0600 85.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 85.3 @@ -1,136 +0,0 @@ 85.4 -/* 85.5 - * bootsect.S 85.6 - * 85.7 - * This is bootsect.S from the linux 2.6.9 sources, 85.8 - * with minor changes for mbootpack. 85.9 - * 85.10 - * 85.11 - * This program is free software; you can redistribute it and/or 85.12 - * modify it under the terms of the GNU General Public License as 85.13 - * published by the Free Software Foundation; either version 2 of the 85.14 - * License, or (at your option) any later version. 85.15 - * 85.16 - * This program is distributed in the hope that it will be useful, 85.17 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 85.18 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 85.19 - * General Public License for more details. 85.20 - * 85.21 - * You should have received a copy of the GNU General Public License 85.22 - * along with this program; if not, write to the Free Software 85.23 - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 85.24 - * 02111-1307, USA. 85.25 - * 85.26 - * $Id: bootsect.S,v 1.2 2005/03/23 10:39:11 tjd21 Exp $ 85.27 - * 85.28 - */ 85.29 - 85.30 -#include "mbootpack.h" 85.31 - 85.32 -/* 85.33 - * bootsect.S Copyright (C) 1991, 1992 Linus Torvalds 85.34 - * 85.35 - * modified by Drew Eckhardt 85.36 - * modified by Bruce Evans (bde) 85.37 - * modified by Chris Noe (May 1999) (as86 -> gas) 85.38 - * gutted by H. Peter Anvin (Jan 2003) 85.39 - * 85.40 - * BIG FAT NOTE: We're in real mode using 64k segments. Therefore segment 85.41 - * addresses must be multiplied by 16 to obtain their respective linear 85.42 - * addresses. To avoid confusion, linear addresses are written using leading 85.43 - * hex while segment addresses are written as segment:offset. 85.44 - * 85.45 - */ 85.46 - 85.47 -/* #include <asm/boot.h> */ 85.48 -/* Definitions we should have got from there */ 85.49 -#define DEF_INITSEG 0x9000 85.50 -#define DEF_SYSSEG 0x1000 85.51 -#define DEF_SETUPSEG 0x9020 85.52 -#define DEF_SYSSIZE 0x7F00 85.53 -#define NORMAL_VGA 0xffff 85.54 -#define EXTENDED_VGA 0xfffe 85.55 -#define ASK_VGA 0xfffd 85.56 - 85.57 - 85.58 -/* SETUPSECTS = 4 */ /* default nr of setup-sectors */ 85.59 -BOOTSEG = 0x07C0 /* original address of boot-sector */ 85.60 -INITSEG = DEF_INITSEG /* we move boot here - out of the way */ 85.61 -SETUPSEG = DEF_SETUPSEG /* setup starts here */ 85.62 -SYSSEG = DEF_SYSSEG /* system loaded at 0x10000 (65536) */ 85.63 -SYSSIZE = DEF_SYSSIZE /* system size: # of 16-byte clicks */ 85.64 - /* to be loaded */ 85.65 -ROOT_DEV = 0 /* ROOT_DEV is now written by "build" */ 85.66 -SWAP_DEV = 0 /* SWAP_DEV is now written by "build" */ 85.67 - 85.68 -#ifndef SVGA_MODE 85.69 -/* #define SVGA_MODE ASK_VGA */ 85.70 -#define SVGA_MODE NORMAL_VGA 85.71 -#endif 85.72 - 85.73 -#ifndef RAMDISK 85.74 -#define RAMDISK 0 85.75 -#endif 85.76 - 85.77 -#ifndef ROOT_RDONLY 85.78 -#define ROOT_RDONLY 1 85.79 -#endif 85.80 - 85.81 -.code16 85.82 -.text 85.83 - 85.84 -.global _start 85.85 -_start: 85.86 - 85.87 - # Normalize the start address 85.88 - jmpl $BOOTSEG, $start2 85.89 - 85.90 -start2: 85.91 - movw %cs, %ax 85.92 - movw %ax, %ds 85.93 - movw %ax, %es 85.94 - movw %ax, %ss 85.95 - movw $0x7c00, %sp 85.96 - sti 85.97 - cld 85.98 - 85.99 - movw $bugger_off_msg, %si 85.100 - 85.101 -msg_loop: 85.102 - lodsb 85.103 - andb %al, %al 85.104 - jz die 85.105 - movb $0xe, %ah 85.106 - movw $7, %bx 85.107 - int $0x10 85.108 - jmp msg_loop 85.109 - 85.110 -die: 85.111 - # Allow the user to press a key, then reboot 85.112 - xorw %ax, %ax 85.113 - int $0x16 85.114 - int $0x19 85.115 - 85.116 - # int 0x19 should never return. In case it does anyway, 85.117 - # invoke the BIOS reset code... 85.118 - ljmp $0xf000,$0xfff0 85.119 - 85.120 - 85.121 -bugger_off_msg: 85.122 - .ascii "Direct booting from floppy is no longer supported.\r\n" 85.123 - .ascii "Please use a boot loader program instead.\r\n" 85.124 - .ascii "\n" 85.125 - .ascii "Remove disk and press any key to reboot . . .\r\n" 85.126 - .byte 0 85.127 - 85.128 - 85.129 - # Kernel attributes; used by setupbegtext 85.130 - 85.131 - .org 497 85.132 -setup_sects: .byte SETUPSECTS 85.133 -root_flags: .word ROOT_RDONLY 85.134 -syssize: .word SYSSIZE 85.135 -swap_dev: .word SWAP_DEV 85.136 -ram_size: .word RAMDISK 85.137 -vid_mode: .word SVGA_MODE 85.138 -root_dev: .word ROOT_DEV 85.139 -boot_flag: .word 0xAA55
86.1 --- a/tools/misc/mbootpack/buildimage.c Sun Oct 22 14:39:15 2006 -0600 86.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 86.3 @@ -1,176 +0,0 @@ 86.4 -/* 86.5 - * buildimage.c 86.6 - * 86.7 - * Takes the memory image of a loaded kernel and modules and repackages 86.8 - * it as a linux bzImage 86.9 - * 86.10 - * Copyright (C) 2003-2004 Tim Deegan (tjd21@cl.cam.ac.uk) 86.11 - * 86.12 - * This program is free software; you can redistribute it and/or 86.13 - * modify it under the terms of the GNU General Public License as 86.14 - * published by the Free Software Foundation; either version 2 of the 86.15 - * License, or (at your option) any later version. 86.16 - * 86.17 - * This program is distributed in the hope that it will be useful, 86.18 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 86.19 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 86.20 - * General Public License for more details. 86.21 - * 86.22 - * You should have received a copy of the GNU General Public License 86.23 - * along with this program; if not, write to the Free Software 86.24 - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 86.25 - * 02111-1307, USA. 86.26 - * 86.27 - * $Id: buildimage.c,v 1.2 2005/03/23 10:39:19 tjd21 Exp $ 86.28 - * 86.29 - */ 86.30 - 86.31 -#include <assert.h> 86.32 -#include <stdio.h> 86.33 -#include <stdlib.h> 86.34 -#include <errno.h> 86.35 -#include <string.h> 86.36 -#include <getopt.h> 86.37 -#include <elf.h> 86.38 -#include <unistd.h> 86.39 -#include <sys/types.h> 86.40 -#include <sys/stat.h> 86.41 -#include <sys/mman.h> 86.42 -#include <asm/page.h> 86.43 - 86.44 -#include "mbootpack.h" 86.45 -#include "mb_header.h" 86.46 - 86.47 - 86.48 -/* We will build an image that a bzImage-capable bootloader will load like 86.49 - * this: 86.50 - * 86.51 - * ============== (0) 86.52 - * (BIOS memory) 86.53 - * -------------- 86.54 - * (Bootloader) 86.55 - * -------------- 86.56 - * bzImage startup code 86.57 - * MBI, command-lines, module info 86.58 - * ============== (0xa0000) 86.59 - * (memory hole) 86.60 - * ============== (0x100000) 86.61 - * Kernel and modules 86.62 - * ============== 86.63 - * 86.64 - * The bzImage startup code is mostly taken straight from the linux kernel 86.65 - * (see bootsect.S, startup.S). It does the usual unpleasant start-of-day 86.66 - * tasks to get to 32-bit protected mode, then sets registers appropriately 86.67 - * and jumps to the kernel's entry address. 86.68 - * 86.69 - * It also does some relocation to make sure the MBI is where we expect it, 86.70 - * and parses the linux command line. 86.71 - */ 86.72 - 86.73 -#define BZ_SETUP_OFFSET (512 * (1 + SETUPSECTS)) 86.74 -#define BZ_ENTRY_OFFSET 0x30 86.75 -#define BZ_MBI_OFFSET 0x34 86.76 -/* These *MUST* fit the offsets of entry_address and mbi_address in setup.S */ 86.77 - 86.78 -/* Bring in the bzImage boot sector and setup code */ 86.79 -#include "bzimage_header.c" 86.80 - 86.81 -#define _p(x) ((void *)(unsigned long)(x)) 86.82 - 86.83 -address_t place_mbi(long int size) 86.84 -/* Find space at the top of *low* memory for the MBI and associated red tape */ 86.85 -{ 86.86 - address_t start; 86.87 - start = 0xa000 - size; 86.88 - if (start < 0x9000 + sizeof(bzimage_bootsect) + sizeof(bzimage_setup)) { 86.89 - printf("Fatal: command-lines too long: need %ld, have %ld bytes\n", 86.90 - size, 86.91 - 0x1000L - (sizeof(bzimage_bootsect) + sizeof(bzimage_setup))); 86.92 - exit(1); 86.93 - } 86.94 - if (!quiet) { 86.95 - printf("Placed MBI and strings (%p+%p)\n", 86.96 - _p(start), _p(size)); 86.97 - } 86.98 - return start; 86.99 -} 86.100 - 86.101 -void make_bzImage(section_t *sections, 86.102 - address_t entry, 86.103 - address_t mbi, 86.104 - FILE *fp) 86.105 -/* Rework this list of sections into a bzImage and write it out to fp */ 86.106 -{ 86.107 - int i; 86.108 - size_t offset; 86.109 - section_t *s; 86.110 - 86.111 - /* Patch the kernel and mbi addresses into the setup code */ 86.112 - *(address_t *)(bzimage_setup + BZ_ENTRY_OFFSET) = eswap(entry); 86.113 - *(address_t *)(bzimage_setup + BZ_MBI_OFFSET) = eswap(mbi); 86.114 - if (!quiet) printf("Kernel entry is %p, MBI is %p.\n",_p(entry), _p(mbi)); 86.115 - 86.116 - /* Write out header and trampoline */ 86.117 - if (fseek(fp, 0, SEEK_SET) < 0) { 86.118 - printf("Fatal: error seeking in output file: %s\n", 86.119 - strerror(errno)); 86.120 - exit(1); 86.121 - } 86.122 - if (fwrite(bzimage_bootsect, sizeof(bzimage_bootsect), 1, fp) != 1) { 86.123 - printf("Fatal: error writing to output file: %s\n", 86.124 - strerror(errno)); 86.125 - exit(1); 86.126 - } 86.127 - if (fwrite(bzimage_setup, sizeof(bzimage_setup), 1, fp) != 1) { 86.128 - printf("Fatal: error writing to output file: %s\n", 86.129 - strerror(errno)); 86.130 - exit(1); 86.131 - } 86.132 - 86.133 - if (!quiet) printf("Wrote bzImage header: %ld + %ld bytes.\n", 86.134 - (long)sizeof(bzimage_bootsect), 86.135 - (long)sizeof(bzimage_setup)); 86.136 - 86.137 - /* Sorted list of sections below 1MB: write them out */ 86.138 - for (s = sections, i = 0; s; s = s->next) { 86.139 - if (s->start >= HIGHMEM_START) continue; 86.140 - offset = (s->start - 0x9000); 86.141 - if (fseek(fp, offset, SEEK_SET) < 0) { 86.142 - printf("Fatal: error seeking in output file: %s\n", 86.143 - strerror(errno)); 86.144 - exit(1); 86.145 - } 86.146 - if (fwrite(s->buffer, s->size, 1, fp) != 1) { 86.147 - printf("Fatal: error writing to output file: %s\n", 86.148 - strerror(errno)); 86.149 - exit(1); 86.150 - } 86.151 - i++; 86.152 - } 86.153 - 86.154 - if (!quiet) printf("Wrote %i low-memory sections.\n", i); 86.155 - 86.156 - /* Sorted list of sections higher than 1MB: write them out */ 86.157 - for (s = sections, i = 0; s; s = s->next) { 86.158 - if (s->start < HIGHMEM_START) continue; 86.159 - offset = (s->start - HIGHMEM_START) + BZ_SETUP_OFFSET; 86.160 - if (fseek(fp, offset, SEEK_SET) < 0) { 86.161 - printf("Fatal: error seeking in output file: %s\n", 86.162 - strerror(errno)); 86.163 - exit(1); 86.164 - } 86.165 - if (fwrite(s->buffer, s->size, 1, fp) != 1) { 86.166 - printf("Fatal: error writing to output file: %s\n", 86.167 - strerror(errno)); 86.168 - exit(1); 86.169 - } 86.170 - i++; 86.171 - } 86.172 - 86.173 - if (!quiet) printf("Wrote %i high-memory sections.\n", i); 86.174 -} 86.175 - 86.176 - 86.177 -/* 86.178 - * EOF(buildimage.c) 86.179 - */
87.1 --- a/tools/misc/mbootpack/mb_header.h Sun Oct 22 14:39:15 2006 -0600 87.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 87.3 @@ -1,90 +0,0 @@ 87.4 -/* 87.5 - * GRUB -- GRand Unified Bootloader 87.6 - * Copyright (C) 2000 Free Software Foundation, Inc. 87.7 - * 87.8 - * This program is free software; you can redistribute it and/or modify 87.9 - * it under the terms of the GNU General Public License as published by 87.10 - * the Free Software Foundation; either version 2 of the License, or 87.11 - * (at your option) any later version. 87.12 - * 87.13 - * This program is distributed in the hope that it will be useful, 87.14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 87.15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 87.16 - * GNU General Public License for more details. 87.17 - * 87.18 - * You should have received a copy of the GNU General Public License 87.19 - * along with this program; if not, write to the Free Software 87.20 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 87.21 - */ 87.22 - 87.23 -/* 87.24 - * MultiBoot Header description 87.25 - */ 87.26 - 87.27 -struct multiboot_header 87.28 -{ 87.29 - /* Must be MULTIBOOT_MAGIC - see below. */ 87.30 - unsigned magic; 87.31 - 87.32 - /* Feature flags - see below. */ 87.33 - unsigned flags; 87.34 - 87.35 - /* 87.36 - * Checksum 87.37 - * 87.38 - * The above fields plus this one must equal 0 mod 2^32. 87.39 - */ 87.40 - unsigned checksum; 87.41 - 87.42 - /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */ 87.43 - unsigned header_addr; 87.44 - unsigned load_addr; 87.45 - unsigned load_end_addr; 87.46 - unsigned bss_end_addr; 87.47 - unsigned entry_addr; 87.48 - 87.49 - /* These are only valid if MULTIBOOT_VIDEO_MODE is set. */ 87.50 - unsigned mode_type; 87.51 - unsigned width; 87.52 - unsigned height; 87.53 - unsigned depth; 87.54 -}; 87.55 - 87.56 -/* 87.57 - * The entire multiboot_header must be contained 87.58 - * within the first MULTIBOOT_SEARCH bytes of the kernel image. 87.59 - */ 87.60 -#define MULTIBOOT_SEARCH 8192 87.61 -#define MULTIBOOT_FOUND(addr, len) \ 87.62 - (! ((addr) & 0x3) \ 87.63 - && (len) >= 12 \ 87.64 - && *((int *) (addr)) == MULTIBOOT_MAGIC \ 87.65 - && ! (*((unsigned *) (addr)) + *((unsigned *) (addr + 4)) \ 87.66 - + *((unsigned *) (addr + 8))) \ 87.67 - && (! (MULTIBOOT_AOUT_KLUDGE & *((int *) (addr + 4))) || (len) >= 32) \ 87.68 - && (! (MULTIBOOT_VIDEO_MODE & *((int *) (addr + 4))) || (len) >= 48)) 87.69 - 87.70 -/* Magic value identifying the multiboot_header. */ 87.71 -#define MULTIBOOT_MAGIC 0x1BADB002 87.72 - 87.73 -/* 87.74 - * Features flags for 'flags'. 87.75 - * If a boot loader sees a flag in MULTIBOOT_MUSTKNOW set 87.76 - * and it doesn't understand it, it must fail. 87.77 - */ 87.78 -#define MULTIBOOT_MUSTKNOW 0x0000FFFF 87.79 - 87.80 -/* currently unsupported flags... this is a kind of version number. */ 87.81 -#define MULTIBOOT_UNSUPPORTED 0x0000FFF8 87.82 - 87.83 -/* Align all boot modules on i386 page (4KB) boundaries. */ 87.84 -#define MULTIBOOT_PAGE_ALIGN 0x00000001 87.85 - 87.86 -/* Must pass memory information to OS. */ 87.87 -#define MULTIBOOT_MEMORY_INFO 0x00000002 87.88 - 87.89 -/* Must pass video information to OS. */ 87.90 -#define MULTIBOOT_VIDEO_MODE 0x00000004 87.91 - 87.92 -/* This flag indicates the use of the address fields in the header. */ 87.93 -#define MULTIBOOT_AOUT_KLUDGE 0x00010000
88.1 --- a/tools/misc/mbootpack/mb_info.h Sun Oct 22 14:39:15 2006 -0600 88.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 88.3 @@ -1,217 +0,0 @@ 88.4 -/* 88.5 - * GRUB -- GRand Unified Bootloader 88.6 - * Copyright (C) 2000 Free Software Foundation, Inc. 88.7 - * 88.8 - * This program is free software; you can redistribute it and/or modify 88.9 - * it under the terms of the GNU General Public License as published by 88.10 - * the Free Software Foundation; either version 2 of the License, or 88.11 - * (at your option) any later version. 88.12 - * 88.13 - * This program is distributed in the hope that it will be useful, 88.14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 88.15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 88.16 - * GNU General Public License for more details. 88.17 - * 88.18 - * You should have received a copy of the GNU General Public License 88.19 - * along with this program; if not, write to the Free Software 88.20 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 88.21 - */ 88.22 - 88.23 -/* 88.24 - * The structure type "mod_list" is used by the "multiboot_info" structure. 88.25 - */ 88.26 - 88.27 -struct mod_list 88.28 -{ 88.29 - /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */ 88.30 - unsigned long mod_start; 88.31 - unsigned long mod_end; 88.32 - 88.33 - /* Module command line */ 88.34 - unsigned long cmdline; 88.35 - 88.36 - /* padding to take it to 16 bytes (must be zero) */ 88.37 - unsigned long pad; 88.38 -}; 88.39 - 88.40 - 88.41 -/* 88.42 - * INT-15, AX=E820 style "AddressRangeDescriptor" 88.43 - * ...with a "size" parameter on the front which is the structure size - 4, 88.44 - * pointing to the next one, up until the full buffer length of the memory 88.45 - * map has been reached. 88.46 - */ 88.47 - 88.48 -struct AddrRangeDesc 88.49 -{ 88.50 - unsigned long size; 88.51 - unsigned long long BaseAddr; 88.52 - unsigned long long Length; 88.53 - unsigned long Type; 88.54 - 88.55 - /* unspecified optional padding... */ 88.56 -}; 88.57 - 88.58 -/* usable memory "Type", all others are reserved. */ 88.59 -#define MB_ARD_MEMORY 1 88.60 - 88.61 - 88.62 -/* Drive Info structure. */ 88.63 -struct drive_info 88.64 -{ 88.65 - /* The size of this structure. */ 88.66 - unsigned long size; 88.67 - 88.68 - /* The BIOS drive number. */ 88.69 - unsigned char drive_number; 88.70 - 88.71 - /* The access mode (see below). */ 88.72 - unsigned char drive_mode; 88.73 - 88.74 - /* The BIOS geometry. */ 88.75 - unsigned short drive_cylinders; 88.76 - unsigned char drive_heads; 88.77 - unsigned char drive_sectors; 88.78 - 88.79 - /* The array of I/O ports used for the drive. */ 88.80 - unsigned short drive_ports[0]; 88.81 -}; 88.82 - 88.83 -/* Drive Mode. */ 88.84 -#define MB_DI_CHS_MODE 0 88.85 -#define MB_DI_LBA_MODE 1 88.86 - 88.87 - 88.88 -/* APM BIOS info. */ 88.89 -struct apm_info 88.90 -{ 88.91 - unsigned short version; 88.92 - unsigned short cseg; 88.93 - unsigned long offset; 88.94 - unsigned short cseg_16; 88.95 - unsigned short dseg_16; 88.96 - unsigned short cseg_len; 88.97 - unsigned short cseg_16_len; 88.98 - unsigned short dseg_16_len; 88.99 -}; 88.100 - 88.101 - 88.102 -/* 88.103 - * MultiBoot Info description 88.104 - * 88.105 - * This is the struct passed to the boot image. This is done by placing 88.106 - * its address in the EAX register. 88.107 - */ 88.108 - 88.109 -struct multiboot_info 88.110 -{ 88.111 - /* MultiBoot info version number */ 88.112 - unsigned long flags; 88.113 - 88.114 - /* Available memory from BIOS */ 88.115 - unsigned long mem_lower; 88.116 - unsigned long mem_upper; 88.117 - 88.118 - /* "root" partition */ 88.119 - unsigned long boot_device; 88.120 - 88.121 - /* Kernel command line */ 88.122 - unsigned long cmdline; 88.123 - 88.124 - /* Boot-Module list */ 88.125 - unsigned long mods_count; 88.126 - unsigned long mods_addr; 88.127 - 88.128 - union 88.129 - { 88.130 - struct 88.131 - { 88.132 - /* (a.out) Kernel symbol table info */ 88.133 - unsigned long tabsize; 88.134 - unsigned long strsize; 88.135 - unsigned long addr; 88.136 - unsigned long pad; 88.137 - } 88.138 - a; 88.139 - 88.140 - struct 88.141 - { 88.142 - /* (ELF) Kernel section header table */ 88.143 - unsigned long num; 88.144 - unsigned long size; 88.145 - unsigned long addr; 88.146 - unsigned long shndx; 88.147 - } 88.148 - e; 88.149 - } 88.150 - syms; 88.151 - 88.152 - /* Memory Mapping buffer */ 88.153 - unsigned long mmap_length; 88.154 - unsigned long mmap_addr; 88.155 - 88.156 - /* Drive Info buffer */ 88.157 - unsigned long drives_length; 88.158 - unsigned long drives_addr; 88.159 - 88.160 - /* ROM configuration table */ 88.161 - unsigned long config_table; 88.162 - 88.163 - /* Boot Loader Name */ 88.164 - unsigned long boot_loader_name; 88.165 - 88.166 - /* APM table */ 88.167 - unsigned long apm_table; 88.168 - 88.169 - /* Video */ 88.170 - unsigned long vbe_control_info; 88.171 - unsigned long vbe_mode_info; 88.172 - unsigned short vbe_mode; 88.173 - unsigned short vbe_interface_seg; 88.174 - unsigned short vbe_interface_off; 88.175 - unsigned short vbe_interface_len; 88.176 -}; 88.177 - 88.178 -/* 88.179 - * Flags to be set in the 'flags' parameter above 88.180 - */ 88.181 - 88.182 -/* is there basic lower/upper memory information? */ 88.183 -#define MB_INFO_MEMORY 0x00000001 88.184 -/* is there a boot device set? */ 88.185 -#define MB_INFO_BOOTDEV 0x00000002 88.186 -/* is the command-line defined? */ 88.187 -#define MB_INFO_CMDLINE 0x00000004 88.188 -/* are there modules to do something with? */ 88.189 -#define MB_INFO_MODS 0x00000008 88.190 - 88.191 -/* These next two are mutually exclusive */ 88.192 - 88.193 -/* is there a symbol table loaded? */ 88.194 -#define MB_INFO_AOUT_SYMS 0x00000010 88.195 -/* is there an ELF section header table? */ 88.196 -#define MB_INFO_ELF_SHDR 0x00000020 88.197 - 88.198 -/* is there a full memory map? */ 88.199 -#define MB_INFO_MEM_MAP 0x00000040 88.200 - 88.201 -/* Is there drive info? */ 88.202 -#define MB_INFO_DRIVE_INFO 0x00000080 88.203 - 88.204 -/* Is there a config table? */ 88.205 -#define MB_INFO_CONFIG_TABLE 0x00000100 88.206 - 88.207 -/* Is there a boot loader name? */ 88.208 -#define MB_INFO_BOOT_LOADER_NAME 0x00000200 88.209 - 88.210 -/* Is there a APM table? */ 88.211 -#define MB_INFO_APM_TABLE 0x00000400 88.212 - 88.213 -/* Is there video information? */ 88.214 -#define MB_INFO_VIDEO_INFO 0x00000800 88.215 - 88.216 -/* 88.217 - * The following value must be present in the EAX register. 88.218 - */ 88.219 - 88.220 -#define MULTIBOOT_VALID 0x2BADB002
89.1 --- a/tools/misc/mbootpack/mbootpack.c Sun Oct 22 14:39:15 2006 -0600 89.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 89.3 @@ -1,704 +0,0 @@ 89.4 -/* 89.5 - * mbootpack.c 89.6 - * 89.7 - * Takes a multiboot image, command-line and modules, and repackages 89.8 - * them as if they were a linux kernel. Only supports a subset of 89.9 - * the multiboot info page options (enough to boot the Xen hypervisor). 89.10 - * 89.11 - * Copyright (C) 2003-2004 Tim Deegan (tjd21@cl.cam.ac.uk) 89.12 - * 89.13 - * Parts based on GNU GRUB, Copyright (C) 2000 Free Software Foundation, Inc 89.14 - * 89.15 - * This program is free software; you can redistribute it and/or 89.16 - * modify it under the terms of the GNU General Public License as 89.17 - * published by the Free Software Foundation; either version 2 of the 89.18 - * License, or (at your option) any later version. 89.19 - * 89.20 - * This program is distributed in the hope that it will be useful, 89.21 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 89.22 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 89.23 - * General Public License for more details. 89.24 - * 89.25 - * You should have received a copy of the GNU General Public License 89.26 - * along with this program; if not, write to the Free Software 89.27 - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 89.28 - * 02111-1307, USA. 89.29 - * 89.30 - * $Id: mbootpack.c,v 1.3 2005/03/23 10:38:36 tjd21 Exp tjd21 $ 89.31 - * 89.32 - */ 89.33 - 89.34 -#define _GNU_SOURCE 89.35 -#include "mbootpack.h" 89.36 - 89.37 -#include <assert.h> 89.38 -#include <stdio.h> 89.39 -#include <stdlib.h> 89.40 -#include <errno.h> 89.41 -#include <string.h> 89.42 -#include <getopt.h> 89.43 -#include <elf.h> 89.44 -#include <unistd.h> 89.45 -#include <sys/types.h> 89.46 -#include <sys/stat.h> 89.47 -#include <sys/mman.h> 89.48 -#include <asm/page.h> 89.49 - 89.50 -/* From GNU GRUB */ 89.51 -#include "mb_header.h" 89.52 -#include "mb_info.h" 89.53 - 89.54 - 89.55 -/* 89.56 - * The plan: Marshal up the multiboot modules and strings as if we 89.57 - * were loading them into memory on a fresh ix86 PC. Attach 89.58 - * a linux bzImage header to the front, which sets up the machine 89.59 - * appropriately and then jumps to the kernel entry address. 89.60 - * 89.61 - * The memory map will be made up roughly like so: 89.62 - * 89.63 - * ============= 89.64 - * multiboot information (mbi) struct 89.65 - * ------- 89.66 - * kernel command line 89.67 - * ------- 89.68 - * bootloader name 89.69 - * ------- 89.70 - * module command lines 89.71 - * ------- 89.72 - * module information structs 89.73 - * ============= 89.74 - * (memory hole) 89.75 - * ============= 89.76 - * kernel 89.77 - * ------------- 89.78 - * module 1 89.79 - * ------------- 89.80 - * module 2 89.81 - * ------------- 89.82 - * . 89.83 - * . 89.84 - * . 89.85 - * 89.86 - * ============== 89.87 - * 89.88 - * 89.89 - * For allocation of memory we assume that the target machine has 'low' 89.90 - * memory from 0 to 640K and 'high' memory starting at 1M. We allocate 89.91 - * the kernel first, wherever it wants to be. After that, sections 89.92 - * are added at the next available aligned address, always in the order 89.93 - * given above, and skipping the memory hole at 640K. Allocated sections 89.94 - * are stored in a linked list of buffers. 89.95 - * 89.96 - * Re-packaging as a bzImage file happens in buildimage.c 89.97 - * 89.98 - */ 89.99 - 89.100 -/* Version */ 89.101 -static const char version_string[] = "mbootpack " MBOOTPACK_VERSION_STRING; 89.102 - 89.103 -/* Flags */ 89.104 -int quiet = 0; 89.105 - 89.106 -/* How much of the start of a kernel we read looking for headers. 89.107 - * Must be >= MULTIBOOT_SEARCH */ 89.108 -#define HEADERBUF_SIZE MULTIBOOT_SEARCH 89.109 - 89.110 - 89.111 -/* Linked list of loaded sections, and a pointer to the next 89.112 - * available space (i.e. just above the highest allocation so far). */ 89.113 -static section_t *sections = NULL; 89.114 -static section_t *last_section = NULL; 89.115 -static address_t next_free_space = 0; 89.116 - 89.117 -static void usage(void) 89.118 -/* If we don't understand the command-line options */ 89.119 -{ 89.120 - printf( 89.121 -"Usage: mbpack [OPTIONS] kernel-image\n\n" 89.122 -" -h --help Print this text.\n" 89.123 -" -q --quiet Only output errors and warnings.\n" 89.124 -" -o --output=filename Output to filename (default \"bzImage\").\n" 89.125 -" -M --multiboot-output Produce a multiboot kernel, not a bzImage\n" 89.126 -" (sets default output file to \"mbImage\").\n" 89.127 -" -c --command-line=STRING Set the kernel command line (DEPRECATED!).\n" 89.128 -" -m --module=\"MOD arg1 arg2...\" Load module MOD with arguments \"arg1...\"\n" 89.129 -" (can be used multiple times).\n" 89.130 -"\n"); 89.131 - exit(1); 89.132 -} 89.133 - 89.134 -#define _p(x) ((void *)(unsigned long)(x)) 89.135 - 89.136 -static void place_kernel_section(address_t start, long int size) 89.137 -/* Place the kernel in memory, checking for the memory hole. */ 89.138 -{ 89.139 - if (start >= MEM_HOLE_END) { 89.140 - /* Above the memory hole: easy */ 89.141 - next_free_space = MAX(next_free_space, start + size); 89.142 - if (!quiet) { 89.143 - printf("Placed kernel section (%p+%p)\n", 89.144 - _p(start), _p(size)); 89.145 - } 89.146 - return; 89.147 - } 89.148 - 89.149 - if (start >= MEM_HOLE_START) { 89.150 - /* In the memory hole. Not so good */ 89.151 - printf("Fatal: kernel load address (%p) is in the memory hole.\n", 89.152 - _p(start)); 89.153 - exit(1); 89.154 - } 89.155 - 89.156 - if (start + size > MEM_HOLE_START) { 89.157 - /* Too big for low memory */ 89.158 - printf("Fatal: kernel (%p+%p) runs into the memory hole.\n", 89.159 - _p(start), _p(size)); 89.160 - exit(1); 89.161 - } 89.162 - 89.163 - /* Kernel loads below the memory hole */ 89.164 - next_free_space = MAX(next_free_space, start + size); 89.165 - 89.166 - if (!quiet) { 89.167 - printf("Placed kernel section (%p+%p)\n", _p(start), _p(size)); 89.168 - } 89.169 -} 89.170 - 89.171 - 89.172 -static address_t place_section(long int size, int align) 89.173 -/* Find the next available place for this section. 89.174 - * "align" must be a power of 2 */ 89.175 -{ 89.176 - address_t start; 89.177 - assert(next_free_space != 0); 89.178 - assert(((~align + 1) & align) == align); 89.179 - 89.180 - start = ROUNDUP_P2(next_free_space, align); 89.181 - 89.182 - /* Check that we don't hit the memory hole */ 89.183 - if (start < MEM_HOLE_END && (start + size) > MEM_HOLE_START) 89.184 - start = ROUNDUP_P2(MEM_HOLE_END, align); 89.185 - 89.186 - next_free_space = start + size; 89.187 - 89.188 - if (!quiet) { 89.189 - printf("Placed section (%p+%p), align=%p\n", 89.190 - _p(start), _p(size), _p(align)); 89.191 - } 89.192 - return start; 89.193 -} 89.194 - 89.195 - 89.196 -static address_t load_kernel(const char *filename) 89.197 -/* Load an elf32/multiboot kernel from this file 89.198 - * Returns the entry address for the kernel. */ 89.199 -{ 89.200 - unsigned int i; 89.201 - address_t start; 89.202 - size_t len; 89.203 - long int size, loadsize; 89.204 - FILE *fp; 89.205 - char *buffer; 89.206 - section_t *sec, *s; 89.207 - Elf32_Ehdr *ehdr; 89.208 - Elf32_Phdr *phdr; 89.209 - struct multiboot_header *mbh; 89.210 - struct stat sb; 89.211 - 89.212 - static char headerbuf[HEADERBUF_SIZE]; 89.213 - 89.214 - /* Stat and open the file */ 89.215 - if (stat(filename, &sb) != 0) { 89.216 - printf("Fatal: cannot stat %s: %s\n", filename, strerror(errno)); 89.217 - exit(1); 89.218 - } 89.219 - if ((fp = fopen(filename, "r")) == NULL) { 89.220 - printf("Fatal: cannot open %s: %s\n", filename, strerror(errno)); 89.221 - exit(1); 89.222 - } 89.223 - 89.224 - /* Load the first 8k of the file */ 89.225 - if (fseek(fp, 0, SEEK_SET) < 0) { 89.226 - printf("Fatal: seek error in %s: %s\n", filename, strerror(errno)); 89.227 - exit(1); 89.228 - } 89.229 - if ((len = fread(headerbuf, 1, HEADERBUF_SIZE, fp)) 89.230 - < HEADERBUF_SIZE) 89.231 - { 89.232 - if (feof(fp)) /* Short file */ 89.233 - { 89.234 - if (len < 12) { 89.235 - printf("Fatal: %s is too short to be a multiboot file.", 89.236 - filename); 89.237 - exit(1); 89.238 - } 89.239 - } else { 89.240 - printf("Fatal: read error in %s: %s\n", filename, strerror(errno)); 89.241 - exit(1); 89.242 - } 89.243 - } 89.244 - 89.245 - /* Sanity-check: is this file compressed? */ 89.246 - if ((headerbuf[0] == '\037' && 89.247 - (headerbuf[1] == '\235' /* .Z */ || 89.248 - headerbuf[1] == '\213' /* .gz */)) || 89.249 - (headerbuf[0] == 'B' && headerbuf[1] == 'Z') /* .bz[2] */) { 89.250 - printf("Warning: %s looks like a compressed file.\n" 89.251 - " You should uncompress it first!\n", filename); 89.252 - } 89.253 - 89.254 - /* Now look for a multiboot header */ 89.255 - for (i = 0; i <= MIN(len - 12, MULTIBOOT_SEARCH - 12); i += 4) 89.256 - { 89.257 - mbh = (struct multiboot_header *)(headerbuf + i); 89.258 - if (eswap(mbh->magic) != MULTIBOOT_MAGIC 89.259 - || ((eswap(mbh->magic)+eswap(mbh->flags)+eswap(mbh->checksum)) 89.260 - & 0xffffffff)) 89.261 - { 89.262 - /* Not a multiboot header */ 89.263 - continue; 89.264 - } 89.265 - if (eswap(mbh->flags) & MULTIBOOT_UNSUPPORTED) { 89.266 - /* Requires options we don't support */ 89.267 - printf("Fatal: found a multiboot header, but it " 89.268 - "requires multiboot options that I\n" 89.269 - "don't understand. Sorry.\n"); 89.270 - exit(1); 89.271 - } 89.272 - if (eswap(mbh->flags) & MULTIBOOT_VIDEO_MODE) { 89.273 - /* Asked for screen mode information */ 89.274 - /* XXX carry on regardless */ 89.275 - printf("Warning: found a multiboot header which asks " 89.276 - "for screen mode information.\n" 89.277 - " This kernel will NOT be given valid" 89.278 - "screen mode information at boot time.\n"); 89.279 - } 89.280 - /* This kernel will do: place and load it */ 89.281 - 89.282 - if (eswap(mbh->flags) & MULTIBOOT_AOUT_KLUDGE) { 89.283 - 89.284 - /* Load using the offsets in the multiboot header */ 89.285 - if(!quiet) 89.286 - printf("Loading %s using multiboot header.\n", filename); 89.287 - 89.288 - /* How much is there? */ 89.289 - start = eswap(mbh->load_addr); 89.290 - if (eswap(mbh->load_end_addr) != 0) 89.291 - loadsize = eswap(mbh->load_end_addr) - eswap(mbh->load_addr); 89.292 - else 89.293 - loadsize = sb.st_size; 89.294 - 89.295 - /* How much memory will it take up? */ 89.296 - if (eswap(mbh->bss_end_addr) != 0) 89.297 - size = eswap(mbh->bss_end_addr) - eswap(mbh->load_addr); 89.298 - else 89.299 - size = loadsize; 89.300 - 89.301 - if (loadsize > size) { 89.302 - printf("Fatal: can't load %ld bytes of kernel into %ld bytes " 89.303 - "of memory.\n", loadsize, size); 89.304 - exit(1); 89.305 - } 89.306 - 89.307 - /* Does it fit where it wants to be? */ 89.308 - place_kernel_section(start, size); 89.309 - 89.310 - /* Load the kernel */ 89.311 - if ((buffer = malloc(size)) == NULL) { 89.312 - printf("Fatal: malloc() for kernel load failed: %s\n", 89.313 - strerror(errno)); 89.314 - exit(1); 89.315 - } 89.316 - if ((fread(buffer, loadsize, 1, fp)) != 1) { 89.317 - printf("Fatal: cannot read %s: %s\n", 89.318 - filename, strerror(errno)); 89.319 - exit(1); 89.320 - } 89.321 - fclose(fp); 89.322 - 89.323 - /* Clear the kernel BSS */ 89.324 - memset(buffer + loadsize, 0, size - loadsize); 89.325 - 89.326 - /* Start off the linked list of sections */ 89.327 - if ((sec = (section_t *)malloc(sizeof (section_t))) == NULL) { 89.328 - printf("Fatal: malloc() for section_t failed: %s\n", 89.329 - strerror(errno)); 89.330 - exit(1); 89.331 - } 89.332 - sec->buffer = buffer; 89.333 - sec->start = start; 89.334 - sec->size = size; 89.335 - sec->next = NULL; 89.336 - sec->prev = NULL; 89.337 - sections = sec; 89.338 - last_section = sec; 89.339 - 89.340 - /* Done. */ 89.341 - if (!quiet) printf("Loaded kernel from %s\n", filename); 89.342 - return eswap(mbh->entry_addr); 89.343 - 89.344 - } else { 89.345 - 89.346 - /* Now look for an ELF32 header */ 89.347 - ehdr = (Elf32_Ehdr *)headerbuf; 89.348 - if (*(unsigned long *)ehdr != eswap(0x464c457f) 89.349 - || ehdr->e_ident[EI_DATA] != ELFDATA2LSB 89.350 - || ehdr->e_ident[EI_CLASS] != ELFCLASS32 89.351 - || eswap(ehdr->e_machine) != EM_386) 89.352 - { 89.353 - printf("Fatal: kernel has neither ELF32/x86 nor multiboot load" 89.354 - " headers.\n"); 89.355 - exit(1); 89.356 - } 89.357 - if (eswap(ehdr->e_phoff) + eswap(ehdr->e_phnum)*sizeof(*phdr) 89.358 - > HEADERBUF_SIZE) { 89.359 - /* Don't expect this will happen with sane kernels */ 89.360 - printf("Fatal: too much ELF for me. Try increasing " 89.361 - "HEADERBUF_SIZE in mbootpack.\n"); 89.362 - exit(1); 89.363 - } 89.364 - if (eswap(ehdr->e_phoff) + eswap(ehdr->e_phnum)*sizeof (*phdr) 89.365 - > len) { 89.366 - printf("Fatal: malformed ELF header overruns EOF.\n"); 89.367 - exit(1); 89.368 - } 89.369 - if (eswap(ehdr->e_phnum) <= 0) { 89.370 - printf("Fatal: ELF kernel has no program headers.\n"); 89.371 - exit(1); 89.372 - } 89.373 - 89.374 - if(!quiet) 89.375 - printf("Loading %s using ELF header.\n", filename); 89.376 - 89.377 - if (eswap(ehdr->e_type) != ET_EXEC 89.378 - || eswap(ehdr->e_version) != EV_CURRENT 89.379 - || eswap(ehdr->e_phentsize) != sizeof (Elf32_Phdr)) { 89.380 - printf("Warning: funny-looking ELF header.\n"); 89.381 - } 89.382 - phdr = (Elf32_Phdr *)(headerbuf + eswap(ehdr->e_phoff)); 89.383 - 89.384 - /* Obey the program headers to load the kernel */ 89.385 - for(i = 0; i < eswap(ehdr->e_phnum); i++) { 89.386 - 89.387 - start = eswap(phdr[i].p_paddr); 89.388 - size = eswap(phdr[i].p_memsz); 89.389 - if (eswap(phdr[i].p_type) != PT_LOAD) 89.390 - loadsize = 0; 89.391 - else 89.392 - loadsize = MIN((long int)eswap(phdr[i].p_filesz), size); 89.393 - 89.394 - if ((buffer = malloc(size)) == NULL) { 89.395 - printf("Fatal: malloc() for kernel load failed: %s\n", 89.396 - strerror(errno)); 89.397 - exit(1); 89.398 - } 89.399 - 89.400 - /* Place the section where it wants to be */ 89.401 - place_kernel_section(start, size); 89.402 - 89.403 - /* Load section from file */ 89.404 - if (loadsize > 0) { 89.405 - if (fseek(fp, eswap(phdr[i].p_offset), SEEK_SET) != 0) { 89.406 - printf("Fatal: seek failed in %s\n", 89.407 - strerror(errno)); 89.408 - exit(1); 89.409 - } 89.410 - if ((fread(buffer, loadsize, 1, fp)) != 1) { 89.411 - printf("Fatal: cannot read %s: %s\n", 89.412 - filename, strerror(errno)); 89.413 - exit(1); 89.414 - } 89.415 - } 89.416 - 89.417 - /* Clear the rest of the buffer */ 89.418 - memset(buffer + loadsize, 0, size - loadsize); 89.419 - 89.420 - /* Add this section to the list (keeping it ordered) */ 89.421 - if ((sec = (section_t *)malloc(sizeof (section_t))) == NULL) { 89.422 - printf("Fatal: malloc() for section_t failed: %s\n", 89.423 - strerror(errno)); 89.424 - exit(1); 89.425 - } 89.426 - sec->buffer = buffer; 89.427 - sec->start = start; 89.428 - sec->size = size; 89.429 - 89.430 - for(s = sections; s; s = s->next) { 89.431 - if (s->start > start) { 89.432 - sec->next = s; 89.433 - if (s->prev == NULL) { 89.434 - /* sec becomes the new first item */ 89.435 - s->prev = sec; 89.436 - sections = sec; 89.437 - } else { 89.438 - /* sec goes between s->prev and s */ 89.439 - sec->prev = s->prev; 89.440 - sec->prev->next = sec; 89.441 - s->prev = sec; 89.442 - } 89.443 - break; 89.444 - } 89.445 - } 89.446 - if (s == NULL) { 89.447 - /* sec becomes the new last item */ 89.448 - sec->next = NULL; 89.449 - sec->prev = last_section; 89.450 - if (last_section) { 89.451 - last_section->next = sec; 89.452 - } else { 89.453 - sections = sec; 89.454 - } 89.455 - last_section = sec; 89.456 - } 89.457 - } 89.458 - 89.459 - /* Done! */ 89.460 - if (!quiet) printf("Loaded kernel from %s\n", filename); 89.461 - return eswap(ehdr->e_entry); 89.462 - } 89.463 - 89.464 - } 89.465 - 89.466 - /* This is not a multiboot kernel */ 89.467 - printf("Fatal: %s is not a multiboot kernel.\n", filename); 89.468 - exit(1); 89.469 -} 89.470 - 89.471 - 89.472 -int main(int argc, char **argv) 89.473 -{ 89.474 - char *buffer, *imagename, *command_line, *p; 89.475 - char *mod_filename, *mod_command_line, *mod_clp; 89.476 - char *out_filename; 89.477 - section_t *sec; 89.478 - FILE *fp; 89.479 - struct stat sb; 89.480 - struct multiboot_info *mbi; 89.481 - struct mod_list *modp; 89.482 - address_t start, kernel_entry; 89.483 - long int size, mod_command_line_space, command_line_len; 89.484 - int modules, opt, mbi_reloc_offset; 89.485 - 89.486 - static const char short_options[] = "hc:m:o:qM"; 89.487 - static const struct option options[] = { 89.488 - { "help", 0, 0, 'h' }, 89.489 - { "command-line", 1, 0, 'c' }, 89.490 - { "append", 1, 0, 'c' }, 89.491 - { "module", 1, 0, 'm' }, 89.492 - { "output", 1, 0, 'o' }, 89.493 - { "quiet", 0, 0, 'q' }, 89.494 - { 0, 0, 0, 0 }, 89.495 - }; 89.496 - 89.497 - /* Parse the command line */ 89.498 - out_filename = NULL; 89.499 - command_line = ""; 89.500 - command_line_len = 0; 89.501 - modules = 0; 89.502 - mod_command_line_space = 0; 89.503 - while((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) 89.504 - { 89.505 - switch(opt) { 89.506 - case 'c': 89.507 - command_line = optarg; 89.508 - break; 89.509 - case 'm': 89.510 - modules++; 89.511 - mod_command_line_space += strlen(optarg) + 1; 89.512 - break; 89.513 - case 'o': 89.514 - out_filename = optarg; 89.515 - break; 89.516 - case 'q': 89.517 - quiet = 1; 89.518 - break; 89.519 - case 'h': 89.520 - case '?': 89.521 - default: 89.522 - usage(); 89.523 - } 89.524 - } 89.525 - imagename = argv[optind]; 89.526 - if (!imagename || strlen(imagename) == 0) usage(); 89.527 - command_line_len = strlen(command_line) + strlen(imagename) + 2; 89.528 - /* Leave space to overwritethe command-line at boot time */ 89.529 - command_line_len = MAX(command_line_len, CMD_LINE_SPACE); 89.530 - if (!out_filename) out_filename = "bzImage"; 89.531 - 89.532 - /* Place and load the kernel */ 89.533 - kernel_entry = load_kernel(imagename); 89.534 - assert(sections != NULL); 89.535 - assert(last_section != NULL); 89.536 - assert(next_free_space != 0); 89.537 - 89.538 - /* Next section is all the metadata between kernel and modules */ 89.539 - size = ((((sizeof (struct multiboot_info) 89.540 - + command_line_len 89.541 - + strlen(version_string) + 1 89.542 - + mod_command_line_space) 89.543 - + 3 ) & ~3) 89.544 - + modules * sizeof (struct mod_list)); 89.545 - /* Locate this section after the setup sectors, in *low* memory */ 89.546 - start = place_mbi(size); 89.547 - 89.548 - if ((buffer = malloc(size)) == NULL) { 89.549 - printf("Fatal: malloc() for boot metadata failed: %s\n", 89.550 - strerror(errno)); 89.551 - exit(1); 89.552 - } 89.553 - 89.554 - if ((sec = (section_t *)malloc(sizeof (section_t))) == NULL) { 89.555 - printf("Fatal: malloc() for section_t failed: %s\n", 89.556 - strerror(errno)); 89.557 - exit(1); 89.558 - } 89.559 - sec->buffer = buffer; 89.560 - sec->start = start; 89.561 - sec->size = size; 89.562 - sec->next = NULL; 89.563 - sec->prev = last_section; 89.564 - last_section->next = sec; 89.565 - last_section = sec; 89.566 - 89.567 - /* Multiboot info struct */ 89.568 - mbi = (struct multiboot_info *)buffer; 89.569 - memset(buffer, 0, sizeof (struct multiboot_info)); 89.570 - mbi_reloc_offset = start - (address_t)buffer; 89.571 - 89.572 - /* Command line */ 89.573 - p = (char *)(mbi + 1); 89.574 - sprintf(p, "%s %s", imagename, command_line); 89.575 - mbi->cmdline = eswap(((address_t)p) + mbi_reloc_offset); 89.576 - p += command_line_len; 89.577 - 89.578 - /* Bootloader ID */ 89.579 - sprintf(p, version_string); 89.580 - mbi->boot_loader_name = eswap(((address_t)p) + mbi_reloc_offset); 89.581 - p += strlen(version_string) + 1; 89.582 - 89.583 - /* Next is space for the module command lines */ 89.584 - mod_clp = p; 89.585 - 89.586 - /* Last come the module info structs */ 89.587 - modp = (struct mod_list *) 89.588 - ((((address_t)p + mod_command_line_space) + 3) & ~3); 89.589 - mbi->mods_count = eswap(modules); 89.590 - mbi->mods_addr = eswap(((address_t)modp) + mbi_reloc_offset); 89.591 - 89.592 - /* Memory information will be added at boot time, by setup.S 89.593 - * or trampoline.S. */ 89.594 - mbi->flags = eswap(MB_INFO_CMDLINE | MB_INFO_BOOT_LOADER_NAME); 89.595 - 89.596 - 89.597 - /* Load the modules */ 89.598 - if (modules) { 89.599 - mbi->flags = eswap(eswap(mbi->flags) | MB_INFO_MODS); 89.600 - 89.601 - /* Go back and parse the module command lines */ 89.602 - optind = opterr = 1; 89.603 - while((opt = getopt_long(argc, argv, 89.604 - short_options, options, 0)) != -1) 89.605 - { 89.606 - if (opt != 'm') continue; 89.607 - 89.608 - /* Split module filename from command line */ 89.609 - mod_command_line = mod_filename = optarg; 89.610 - if ((p = strchr(mod_filename, ' ')) != NULL) { 89.611 - /* See as I discard the 'const' modifier */ 89.612 - *p = '\0'; 89.613 - } 89.614 - 89.615 - /* Find space for it */ 89.616 - if (stat(mod_filename, &sb) != 0) { 89.617 - printf("Fatal: cannot stat %s: %s\n", 89.618 - mod_filename, strerror(errno)); 89.619 - exit(1); 89.620 - } 89.621 - size = sb.st_size; 89.622 - start = place_section(size, X86_PAGE_SIZE); 89.623 - /* XXX should be place_section(size, 4) if the MBH hasn't got 89.624 - * XXX MULTIBOOT_PAGE_ALIGN set, but that breaks Xen */ 89.625 - 89.626 - /* Load it */ 89.627 - if ((buffer = malloc(sb.st_size)) == NULL) { 89.628 - printf("Fatal: malloc failed for module load: %s\n", 89.629 - strerror(errno)); 89.630 - exit(1); 89.631 - } 89.632 - if ((fp = fopen(mod_filename, "r")) == NULL) { 89.633 - printf("Fatal: cannot open %s: %s\n", 89.634 - mod_filename, strerror(errno)); 89.635 - exit(1); 89.636 - } 89.637 - if ((fread(buffer, sb.st_size, 1, fp)) != 1) { 89.638 - printf("Fatal: cannot read %s: %s\n", 89.639 - mod_filename, strerror(errno)); 89.640 - exit(1); 89.641 - } 89.642 - fclose(fp); 89.643 - 89.644 - /* Sanity-check: is this file compressed? */ 89.645 - if ((buffer[0] == '\037' && 89.646 - (buffer[1] == '\235' /* .Z */ || 89.647 - buffer[1] == '\213' /* .gz */)) || 89.648 - (buffer[0] == 'B' && buffer[1] == 'Z') /* .bz[2] */) { 89.649 - printf("Warning: %s looks like a compressed file.\n", 89.650 - mod_filename); 89.651 - } 89.652 - 89.653 - if (!quiet) printf("Loaded module from %s\n", mod_filename); 89.654 - 89.655 - /* Restore the command line to its former glory */ 89.656 - if (p != NULL) *p = ' '; 89.657 - 89.658 - /* Fill in the module info struct */ 89.659 - modp->mod_start = eswap(start); 89.660 - modp->mod_end = eswap(start + size); 89.661 - modp->cmdline = eswap((address_t)mod_clp + mbi_reloc_offset); 89.662 - modp->pad = eswap(0); 89.663 - modp++; 89.664 - 89.665 - /* Store the module command line */ 89.666 - sprintf(mod_clp, "%s", mod_command_line); 89.667 - mod_clp += strlen(mod_clp) + 1; 89.668 - 89.669 - /* Add the section to the list */ 89.670 - if ((sec = (section_t *)malloc(sizeof (section_t))) == NULL) { 89.671 - printf("Fatal: malloc() for section_t failed: %s\n", 89.672 - strerror(errno)); 89.673 - exit(1); 89.674 - } 89.675 - sec->buffer = buffer; 89.676 - sec->start = start; 89.677 - sec->size = size; 89.678 - sec->next = NULL; 89.679 - sec->prev = last_section; 89.680 - last_section->next = sec; 89.681 - last_section = sec; 89.682 - 89.683 - } 89.684 - 89.685 - } 89.686 - 89.687 - /* Everything is placed and loaded. Now we package it all up 89.688 - * as a bzImage */ 89.689 - if ((fp = fopen(out_filename, "w")) == NULL) { 89.690 - printf("Fatal: cannot open %s: %s\n", out_filename, strerror(errno)); 89.691 - exit(1); 89.692 - } 89.693 - make_bzImage(sections, 89.694 - kernel_entry, 89.695 - ((address_t)mbi) + mbi_reloc_offset, 89.696 - fp); 89.697 - fclose(fp); 89.698 - 89.699 - /* Success! */ 89.700 - if(!quiet) printf("Finished.\n"); 89.701 - return 0; 89.702 -} 89.703 - 89.704 -/* 89.705 - * EOF (mbootpack.c) 89.706 - */ 89.707 -
90.1 --- a/tools/misc/mbootpack/mbootpack.h Sun Oct 22 14:39:15 2006 -0600 90.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 90.3 @@ -1,109 +0,0 @@ 90.4 -/* 90.5 - * mbootpack.h 90.6 - * 90.7 - * Common definitions for mbootpack 90.8 - * 90.9 - * Copyright (C) 2003-2004 Tim Deegan (tjd21@cl.cam.ac.uk) 90.10 - * 90.11 - * This program is free software; you can redistribute it and/or 90.12 - * modify it under the terms of the GNU General Public License as 90.13 - * published by the Free Software Foundation; either version 2 of the 90.14 - * License, or (at your option) any later version. 90.15 - * 90.16 - * This program is distributed in the hope that it will be useful, 90.17 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 90.18 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 90.19 - * General Public License for more details. 90.20 - * 90.21 - * You should have received a copy of the GNU General Public License 90.22 - * along with this program; if not, write to the Free Software 90.23 - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 90.24 - * 02111-1307, USA. 90.25 - * 90.26 - * $Id: mbootpack.h,v 1.2 2005/03/23 10:38:37 tjd21 Exp $ 90.27 - * 90.28 - */ 90.29 - 90.30 -#ifndef __MBOOTPACK__H__ 90.31 -#define __MBOOTPACK__H__ 90.32 - 90.33 -#ifndef __MB_ASM 90.34 - 90.35 -#undef NDEBUG 90.36 -#include <stdio.h> 90.37 - 90.38 -#include <endian.h> 90.39 -#include <byteswap.h> 90.40 -#if __BYTE_ORDER == __LITTLE_ENDIAN 90.41 -#define eswap(x) (x) 90.42 -#else 90.43 -#define eswap(x) \ 90.44 - ({ \ 90.45 - typeof(x) y = (x); \ 90.46 - switch(sizeof(y)) \ 90.47 - { \ 90.48 - case 2: y = __bswap_16(y); break; \ 90.49 - case 4: y = __bswap_32(y); break; \ 90.50 - case 8: y = __bswap_64(y); break; \ 90.51 - } \ 90.52 - y; \ 90.53 - }) 90.54 -#endif 90.55 - 90.56 -/* Flags */ 90.57 -extern int quiet; 90.58 - 90.59 -/* Types */ 90.60 -typedef unsigned long address_t; 90.61 - 90.62 -typedef struct section_t { 90.63 - char *buffer; 90.64 - address_t start; 90.65 - long int size; 90.66 - struct section_t *prev; 90.67 - struct section_t *next; 90.68 -} section_t; 90.69 - 90.70 -/* buildimage.c */ 90.71 -extern void make_bzImage(section_t *sections, 90.72 - address_t entry, 90.73 - address_t mbi, 90.74 - FILE *fp); 90.75 - 90.76 -address_t place_mbi(long int size); 90.77 - 90.78 - 90.79 -/* trampoline.S */ 90.80 -extern unsigned char mb_trampoline[]; 90.81 -extern unsigned char mb_trampoline_end[]; 90.82 -extern volatile address_t mb_mbi_address, mb_entry_address; 90.83 - 90.84 -/* Macros */ 90.85 -#define MIN(_x,_y) (((_x)<=(_y))?(_x):(_y)) 90.86 -#define MAX(_x,_y) (((_x)<=(_y))?(_y):(_x)) 90.87 -#define ROUNDUP_P2(_x, _a) (((_x)+((_a)-1))&(~((_a)-1))) 90.88 - 90.89 -#endif 90.90 - 90.91 -/* x86 memory: such fun */ 90.92 -#define MEM_HOLE_START 0xa0000 90.93 -#define MEM_HOLE_END 0x100000 90.94 -#define HIGHMEM_START MEM_HOLE_END 90.95 -#define X86_PAGE_SIZE 0x1000 90.96 - 90.97 -/* How much command line we'll take from the bootloader. */ 90.98 -#define CMD_LINE_SPACE 0x300 90.99 - 90.100 -/* Number of 512-byte sectors to load in low memory (max 7) */ 90.101 -#define SETUPSECTS 7 90.102 - 90.103 - 90.104 -/* Who are we? */ 90.105 -#define MBOOTPACK_VERSION_STRING "v0.2 (alpha)" 90.106 - 90.107 -#endif /* __MBOOTPACK__H__ */ 90.108 - 90.109 -/* 90.110 - * EOF (mbootpack.h) 90.111 - */ 90.112 -
91.1 --- a/tools/misc/mbootpack/setup.S Sun Oct 22 14:39:15 2006 -0600 91.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 91.3 @@ -1,1064 +0,0 @@ 91.4 -/* 91.5 - * bootsect.S 91.6 - * 91.7 - * This is setup.S from the linux 2.6.9 source code, 91.8 - * with heavy cuts and changes for mbootpack 91.9 - * November 2004 Tim Deegan <tjd21@cl.cam.ac.uk> 91.10 - * 91.11 - * 91.12 - * This program is free software; you can redistribute it and/or 91.13 - * modify it under the terms of the GNU General Public License as 91.14 - * published by the Free Software Foundation; either version 2 of the 91.15 - * License, or (at your option) any later version. 91.16 - * 91.17 - * This program is distributed in the hope that it will be useful, 91.18 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 91.19 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 91.20 - * General Public License for more details. 91.21 - * 91.22 - * You should have received a copy of the GNU General Public License 91.23 - * along with this program; if not, write to the Free Software 91.24 - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 91.25 - * 02111-1307, USA. 91.26 - * 91.27 - * $Id: setup.S,v 1.4 2005/03/23 10:39:03 tjd21 Exp $ 91.28 - * 91.29 - */ 91.30 - 91.31 -#include "mbootpack.h" 91.32 - 91.33 -/* 91.34 - * setup.S Copyright (C) 1991, 1992 Linus Torvalds 91.35 - * 91.36 - * setup.s is responsible for getting the system data from the BIOS, 91.37 - * and putting them into the appropriate places in system memory. 91.38 - * both setup.s and system has been loaded by the bootblock. 91.39 - * 91.40 - * This code asks the bios for memory/disk/other parameters, and 91.41 - * puts them in a "safe" place: 0x90000-0x901FF, ie where the 91.42 - * boot-block used to be. It is then up to the protected mode 91.43 - * system to read them from there before the area is overwritten 91.44 - * for buffer-blocks. 91.45 - * 91.46 - * Move PS/2 aux init code to psaux.c 91.47 - * (troyer@saifr00.cfsat.Honeywell.COM) 03Oct92 91.48 - * 91.49 - * some changes and additional features by Christoph Niemann, 91.50 - * March 1993/June 1994 (Christoph.Niemann@linux.org) 91.51 - * 91.52 - * add APM BIOS checking by Stephen Rothwell, May 1994 91.53 - * (sfr@canb.auug.org.au) 91.54 - * 91.55 - * High load stuff, initrd support and position independency 91.56 - * by Hans Lermen & Werner Almesberger, February 1996 91.57 - * <lermen@elserv.ffm.fgan.de>, <almesber@lrc.epfl.ch> 91.58 - * 91.59 - * Video handling moved to video.S by Martin Mares, March 1996 91.60 - * <mj@k332.feld.cvut.cz> 91.61 - * 91.62 - * Extended memory detection scheme retwiddled by orc@pell.chi.il.us (david 91.63 - * parsons) to avoid loadlin confusion, July 1997 91.64 - * 91.65 - * Transcribed from Intel (as86) -> AT&T (gas) by Chris Noe, May 1999. 91.66 - * <stiker@northlink.com> 91.67 - * 91.68 - * Fix to work around buggy BIOSes which dont use carry bit correctly 91.69 - * and/or report extended memory in CX/DX for e801h memory size detection 91.70 - * call. As a result the kernel got wrong figures. The int15/e801h docs 91.71 - * from Ralf Brown interrupt list seem to indicate AX/BX should be used 91.72 - * anyway. So to avoid breaking many machines (presumably there was a reason 91.73 - * to orginally use CX/DX instead of AX/BX), we do a kludge to see 91.74 - * if CX/DX have been changed in the e801 call and if so use AX/BX . 91.75 - * Michael Miller, April 2001 <michaelm@mjmm.org> 91.76 - * 91.77 - * New A20 code ported from SYSLINUX by H. Peter Anvin. AMD Elan bugfixes 91.78 - * by Robert Schwebel, December 2001 <robert@schwebel.de> 91.79 - */ 91.80 - 91.81 -/* 91.82 -#include <linux/config.h> 91.83 -#include <asm/segment.h> 91.84 -#include <linux/version.h> 91.85 -#include <linux/compile.h> 91.86 -#include <asm/boot.h> 91.87 -#include <asm/e820.h> 91.88 -#include <asm/page.h> 91.89 -*/ 91.90 - 91.91 -/* Definitions that should have come from these includes */ 91.92 -#define DEF_INITSEG 0x9000 91.93 -#define DEF_SYSSEG 0x1000 91.94 -#define DEF_SETUPSEG 0x9020 91.95 -#define DEF_SYSSIZE 0x7F00 91.96 -#define NORMAL_VGA 0xffff 91.97 -#define EXTENDED_VGA 0xfffe 91.98 -#define ASK_VGA 0xfffd 91.99 -#define GDT_ENTRY_BOOT_CS 2 91.100 -#define __BOOT_CS (GDT_ENTRY_BOOT_CS * 8) 91.101 -#define GDT_ENTRY_BOOT_DS (GDT_ENTRY_BOOT_CS + 1) 91.102 -#define __BOOT_DS (GDT_ENTRY_BOOT_DS * 8) 91.103 -#define __PAGE_OFFSET (0xC0000000) 91.104 -#define E820MAP 0x2d0 /* our map */ 91.105 -#define E820MAX 32 /* number of entries in E820MAP */ 91.106 -#define E820NR 0x1e8 /* # entries in E820MAP */ 91.107 -#define E820_RAM 1 91.108 -#define E820_RESERVED 2 91.109 -#define E820_ACPI 3 /* usable as RAM once ACPI tables have been read */ 91.110 -#define E820_NVS 4 91.111 -#define __BIG_KERNEL__ 91.112 - 91.113 - 91.114 -/* Signature words to ensure LILO loaded us right */ 91.115 -#define SIG1 0xAA55 91.116 -#define SIG2 0x5A5A 91.117 - 91.118 -INITSEG = DEF_INITSEG # 0x9000, we move boot here, out of the way 91.119 -SYSSEG = DEF_SYSSEG # 0x1000, system loaded at 0x10000 (65536). 91.120 -SETUPSEG = DEF_SETUPSEG # 0x9020, this is the current segment 91.121 - # ... and the former contents of CS 91.122 - 91.123 -DELTA_INITSEG = SETUPSEG - INITSEG # 0x0020 91.124 - 91.125 -.code16 91.126 -.globl _start, begtext, begdata, begbss, endtext, enddata, endbss 91.127 - 91.128 -.text 91.129 -begtext: 91.130 -.data 91.131 -begdata: 91.132 -.bss 91.133 -begbss: 91.134 -.text 91.135 - 91.136 -_start: 91.137 -start: 91.138 - jmp trampoline 91.139 - 91.140 -# This is the setup header, and it must start at %cs:2 (old 0x9020:2) 91.141 - 91.142 - .ascii "HdrS" # header signature 91.143 - .word 0x0203 # header version number (>= 0x0105) 91.144 - # or else old loadlin-1.5 will fail) 91.145 -realmode_swtch: .word 0, 0 # default_switch, SETUPSEG 91.146 -start_sys_seg: .word SYSSEG 91.147 - .word kernel_version # pointing to kernel version string 91.148 - # above section of header is compatible 91.149 - # with loadlin-1.5 (header v1.5). Don't 91.150 - # change it. 91.151 - 91.152 -type_of_loader: .byte 0 # = 0, old one (LILO, Loadlin, 91.153 - # Bootlin, SYSLX, bootsect...) 91.154 - # See Documentation/i386/boot.txt for 91.155 - # assigned ids 91.156 - 91.157 -# flags, unused bits must be zero (RFU) bit within loadflags 91.158 -loadflags: 91.159 -LOADED_HIGH = 1 # If set, the kernel is loaded high 91.160 -CAN_USE_HEAP = 0x80 # If set, the loader also has set 91.161 - # heap_end_ptr to tell how much 91.162 - # space behind setup.S can be used for 91.163 - # heap purposes. 91.164 - # Only the loader knows what is free 91.165 -#ifndef __BIG_KERNEL__ 91.166 - .byte 0 91.167 -#else 91.168 - .byte LOADED_HIGH 91.169 -#endif 91.170 - 91.171 -setup_move_size: .word 0x8000 # size to move, when setup is not 91.172 - # loaded at 0x90000. We will move setup 91.173 - # to 0x90000 then just before jumping 91.174 - # into the kernel. However, only the 91.175 - # loader knows how much data behind 91.176 - # us also needs to be loaded. 91.177 - 91.178 -/* N.B. these next addresses are entirely ignored by this code -- it 91.179 - * assumes it was loaded with the 32bit code at 0x100000, and doesn't 91.180 - * touch the ramdisk. */ 91.181 -code32_start: # here loaders can put a different 91.182 - # start address for 32-bit code. 91.183 -#ifndef __BIG_KERNEL__ 91.184 - .long 0x1000 # 0x1000 = default for zImage 91.185 -#else 91.186 - .long 0x100000 # 0x100000 = default for big kernel 91.187 -#endif 91.188 - 91.189 -ramdisk_image: .long 0 # address of loaded ramdisk image 91.190 - # Here the loader puts the 32-bit 91.191 - # address where it loaded the image. 91.192 - # This only will be read by the kernel. 91.193 - 91.194 -ramdisk_size: .long 0 # its size in bytes 91.195 - 91.196 -bootsect_kludge: 91.197 - .long 0 # obsolete 91.198 - 91.199 -heap_end_ptr: .word modelist+1024 # (Header version 0x0201 or later) 91.200 - # space from here (exclusive) down to 91.201 - # end of setup code can be used by setup 91.202 - # for local heap purposes. 91.203 - 91.204 -pad1: .word 0 91.205 -cmd_line_ptr: .long 0 # (Header version 0x0202 or later) 91.206 - # If nonzero, a 32-bit pointer 91.207 - # to the kernel command line. 91.208 - # The command line should be 91.209 - # located between the start of 91.210 - # setup and the end of low 91.211 - # memory (0xa0000), or it may 91.212 - # get overwritten before it 91.213 - # gets read. If this field is 91.214 - # used, there is no longer 91.215 - # anything magical about the 91.216 - # 0x90000 segment; the setup 91.217 - # can be located anywhere in 91.218 - # low memory 0x10000 or higher. 91.219 - 91.220 -ramdisk_max: .long (-__PAGE_OFFSET-(512 << 20)-1) & 0x7fffffff 91.221 - # (Header version 0x0203 or later) 91.222 - # The highest safe address for 91.223 - # the contents of an initrd 91.224 - 91.225 -/* Add more known locations: the image builder will overwrite 91.226 - * these with the entry point and MBI location for the multiboot kernel. 91.227 - * These offsets *must* match the definitions in buildimage.c */ 91.228 - 91.229 -entry_address: .long 0 # This will be offset 0x30 (0x230 from b'sect) 91.230 -mbi_address: .long 0 # This will be offset 0x34 91.231 - 91.232 -/* Storage space for the size of memory */ 91.233 -highmem_size: .long 0 91.234 - 91.235 -trampoline: call start_of_setup 91.236 - .space 1024 91.237 -# End of setup header ##################################################### 91.238 - 91.239 -start_of_setup: 91.240 -# Bootlin depends on this being done early 91.241 - movw $0x01500, %ax 91.242 - movb $0x81, %dl 91.243 - int $0x13 91.244 - 91.245 -#ifdef SAFE_RESET_DISK_CONTROLLER 91.246 -# Reset the disk controller. 91.247 - movw $0x0000, %ax 91.248 - movb $0x80, %dl 91.249 - int $0x13 91.250 -#endif 91.251 - 91.252 -# Set %ds = %cs, we know that SETUPSEG = %cs at this point 91.253 - movw %cs, %ax # aka SETUPSEG 91.254 - movw %ax, %ds 91.255 - 91.256 -# Check signature at end of setup 91.257 - cmpw $SIG1, setup_sig1 91.258 - jne bad_sig 91.259 - 91.260 - cmpw $SIG2, setup_sig2 91.261 - jne bad_sig 91.262 - 91.263 - jmp good_sig1 91.264 - 91.265 -# Routine to print asciiz string at ds:si 91.266 -prtstr: 91.267 - lodsb 91.268 - andb %al, %al 91.269 - jz fin 91.270 - 91.271 - call prtchr 91.272 - jmp prtstr 91.273 - 91.274 -fin: ret 91.275 - 91.276 -# Space printing 91.277 -prtsp2: call prtspc # Print double space 91.278 -prtspc: movb $0x20, %al # Print single space (note: fall-thru) 91.279 - 91.280 -# Part of above routine, this one just prints ascii al 91.281 -prtchr: pushw %ax 91.282 - pushw %cx 91.283 - movw $7,%bx 91.284 - movw $0x01, %cx 91.285 - movb $0x0e, %ah 91.286 - int $0x10 91.287 - popw %cx 91.288 - popw %ax 91.289 - ret 91.290 - 91.291 -beep: movb $0x07, %al 91.292 - jmp prtchr 91.293 - 91.294 -no_sig_mess: .string "No setup signature found ..." 91.295 - 91.296 -good_sig1: 91.297 - jmp good_sig 91.298 - 91.299 -# We now have to find the rest of the setup code/data 91.300 -bad_sig: 91.301 - movw %cs, %ax # SETUPSEG 91.302 - subw $DELTA_INITSEG, %ax # INITSEG 91.303 - movw %ax, %ds 91.304 - xorb %bh, %bh 91.305 - movb (497), %bl # get setup sect from bootsect 91.306 - subw $4, %bx # LILO loads 4 sectors of setup 91.307 - shlw $8, %bx # convert to words (1sect=2^8 words) 91.308 - movw %bx, %cx 91.309 - shrw $3, %bx # convert to segment 91.310 - addw $SYSSEG, %bx 91.311 - movw %bx, %cs:start_sys_seg 91.312 -# Move rest of setup code/data to here 91.313 - movw $2048, %di # four sectors loaded by LILO 91.314 - subw %si, %si 91.315 - pushw %cs 91.316 - popw %es 91.317 - movw $SYSSEG, %ax 91.318 - movw %ax, %ds 91.319 - rep 91.320 - movsw 91.321 - movw %cs, %ax # aka SETUPSEG 91.322 - movw %ax, %ds 91.323 - cmpw $SIG1, setup_sig1 91.324 - jne no_sig 91.325 - 91.326 - cmpw $SIG2, setup_sig2 91.327 - jne no_sig 91.328 - 91.329 - jmp good_sig 91.330 - 91.331 -no_sig: 91.332 - lea no_sig_mess, %si 91.333 - call prtstr 91.334 - 91.335 -no_sig_loop: 91.336 - hlt 91.337 - jmp no_sig_loop 91.338 - 91.339 -mb_hello_mess1: 91.340 - .string "mboot" 91.341 - 91.342 -good_sig: 91.343 - lea mb_hello_mess1, %si 91.344 - call prtstr 91.345 - 91.346 - movw %cs, %ax # aka SETUPSEG 91.347 - subw $DELTA_INITSEG, %ax # aka INITSEG 91.348 - movw %ax, %ds 91.349 -# Check if an old loader tries to load a big-kernel 91.350 - testb $LOADED_HIGH, %cs:loadflags # Do we have a big kernel? 91.351 - jz loader_ok # No, no danger for old loaders. 91.352 - 91.353 - cmpb $0, %cs:type_of_loader # Do we have a loader that 91.354 - # can deal with us? 91.355 - jnz loader_ok # Yes, continue. 91.356 - 91.357 - pushw %cs # No, we have an old loader, 91.358 - popw %ds # die. 91.359 - lea loader_panic_mess, %si 91.360 - call prtstr 91.361 - 91.362 - jmp no_sig_loop 91.363 - 91.364 -loader_panic_mess: .string "Wrong loader, giving up..." 91.365 - 91.366 -loader_ok: 91.367 - 91.368 -# Get memory size (extended mem, kB) 91.369 - 91.370 -/* We'll be storing this in highmem_size, to be copied to the mbi */ 91.371 - 91.372 -# Try three different memory detection schemes. First, try 91.373 -# e820h, which lets us assemble a memory map, then try e801h, 91.374 -# which returns a 32-bit memory size, and finally 88h, which 91.375 -# returns 0-64m 91.376 - 91.377 - xorl %edx, %edx 91.378 - xorl %eax, %eax 91.379 - movl %eax, (0x1e0) 91.380 - movl %eax, highmem_size 91.381 - movb %al, (E820NR) 91.382 - 91.383 -# method E820H: 91.384 -# the memory map from hell. e820h returns memory classified into 91.385 -# a whole bunch of different types, and allows memory holes and 91.386 -# everything. We scan through this memory map and build a list 91.387 -# of the first 32 memory areas, which we return at [E820MAP]. 91.388 -# This is documented at http://www.acpi.info/, in the ACPI 2.0 specification. 91.389 - 91.390 -#define SMAP 0x534d4150 91.391 - 91.392 -meme820: 91.393 - xorl %ebx, %ebx # continuation counter 91.394 - movw $E820MAP, %di # point into the whitelist 91.395 - # so we can have the bios 91.396 - # directly write into it. 91.397 - 91.398 -jmpe820: 91.399 - movl $0x0000e820, %eax # e820, upper word zeroed 91.400 - movl $SMAP, %edx # ascii 'SMAP' 91.401 - movl $20, %ecx # size of the e820rec 91.402 - pushw %ds # data record. 91.403 - popw %es 91.404 - int $0x15 # make the call 91.405 - jc bail820 # fall to e801 if it fails 91.406 - 91.407 - cmpl $SMAP, %eax # check the return is `SMAP' 91.408 - jne bail820 # fall to e801 if it fails 91.409 - 91.410 -# cmpl $1, 16(%di) # is this usable memory? 91.411 -# jne again820 91.412 - 91.413 - # If this is usable memory, we save it by simply advancing %di by 91.414 - # sizeof(e820rec). 91.415 - # 91.416 -good820: 91.417 - movb (E820NR), %al # up to 32 entries 91.418 - cmpb $E820MAX, %al 91.419 - jnl bail820 91.420 - 91.421 - incb (E820NR) 91.422 - movw %di, %ax 91.423 - addw $20, %ax 91.424 - movw %ax, %di 91.425 -again820: 91.426 - cmpl $0, %ebx # check to see if 91.427 - jne jmpe820 # %ebx is set to EOF 91.428 - 91.429 -/* Multiboot spec says high mem should be the address of the first 91.430 - * upper memory hole, minus 1 MB */ 91.431 - xorl %ebx, %ebx 91.432 - xorl %ecx, %ecx 91.433 - xorl %edx, %edx 91.434 - movw $E820MAP, %di # Start at the beginning 91.435 -calc_highmem_loop: 91.436 - cmpl $1, 16(%di) # is it usable memory? 91.437 - jnz calc_highmem_next 91.438 - cmpl $0, 4(%di) # is base < 4GB? 91.439 - jnz calc_highmem_next 91.440 - cmpl $0x100000, 0(%di) # is base <= 1MB? 91.441 - jg calc_highmem_next 91.442 - movl 8(%di), %ecx # Calculate base+length 91.443 - shrl $10, %ecx # in kilobytes 91.444 - movl 12(%di), %edx 91.445 - shll $22, %edx 91.446 - orl %edx, %ecx 91.447 - movl 0(%di), %edx 91.448 - shrl $10, %edx 91.449 - addl %edx, %ecx 91.450 - subl $1024, %ecx # - 1 MB 91.451 - cmpl %cs:highmem_size, %ecx 91.452 - jl calc_highmem_next 91.453 - movl %ecx, %cs:highmem_size 91.454 -calc_highmem_next: 91.455 - add $1, %bl 91.456 - add $20, %di 91.457 - cmp %bl, (E820NR) 91.458 - je calc_highmem_done 91.459 - jmp calc_highmem_loop 91.460 -calc_highmem_done: 91.461 - 91.462 -bail820: 91.463 - 91.464 -# method E801H: 91.465 -# memory size is in 1k chunksizes, to avoid confusing loadlin. 91.466 - 91.467 -meme801: 91.468 - stc # fix to work around buggy 91.469 - xorw %cx,%cx # BIOSes which dont clear/set 91.470 - xorw %dx,%dx # carry on pass/error of 91.471 - # e801h memory size call 91.472 - # or merely pass cx,dx though 91.473 - # without changing them. 91.474 - movw $0xe801, %ax 91.475 - int $0x15 91.476 - jc mem88 91.477 - 91.478 - cmpw $0x0, %cx # Kludge to handle BIOSes 91.479 - jne e801usecxdx # which report their extended 91.480 - cmpw $0x0, %dx # memory in AX/BX rather than 91.481 - jne e801usecxdx # CX/DX. The spec I have read 91.482 - movw %ax, %cx # seems to indicate AX/BX 91.483 - movw %bx, %dx # are more reasonable anyway... 91.484 - 91.485 -e801usecxdx: 91.486 - andl $0xffff, %edx # clear sign extend 91.487 - shll $6, %edx # and go from 64k to 1k chunks 91.488 - andl $0xffff, %ecx # clear sign extend 91.489 - addl %ecx, %edx 91.490 - 91.491 - cmpl %cs:highmem_size, %edx # store extended mem size 91.492 - jl mem88 # if it's bigger than 91.493 - movl %edx, %cs:highmem_size # what we already have 91.494 - 91.495 -# Ye Olde Traditional Methode. Returns the memory size (up to 16mb or 91.496 -# 64mb, depending on the bios) in ax. 91.497 -mem88: 91.498 - movb $0x88, %ah 91.499 - int $0x15 91.500 - 91.501 - andl $0xffff, %eax # clear sign extend 91.502 - cmpl %cs:highmem_size, %eax # store extended mem size 91.503 - jl have_memsize # if it's bigger than 91.504 - movl %eax, %cs:highmem_size # what we already have 91.505 - 91.506 -have_memsize: 91.507 - 91.508 -/* Culled: HDD probes, APM, speedstep */ 91.509 - 91.510 -# Now we want to move to protected mode ... 91.511 - cmpw $0, %cs:realmode_swtch 91.512 - jz rmodeswtch_normal 91.513 - 91.514 - lcall *%cs:realmode_swtch 91.515 - 91.516 - jmp rmodeswtch_end 91.517 - 91.518 -rmodeswtch_normal: 91.519 - pushw %cs 91.520 - call default_switch 91.521 - 91.522 -rmodeswtch_end: 91.523 - 91.524 -/* Culled: code to take the 32bit entry address from the loader */ 91.525 -/* Culled: code to relocate non-bzImage kernels */ 91.526 - 91.527 - # then we load the segment descriptors 91.528 - movw %cs, %ax # aka SETUPSEG 91.529 - movw %ax, %ds 91.530 - 91.531 -# Check whether we need to be downward compatible with version <=201 91.532 - cmpl $0, cmd_line_ptr 91.533 - jne end_move_self # loader uses version >=202 features 91.534 - cmpb $0x20, type_of_loader 91.535 - je end_move_self # bootsect loader, we know of it 91.536 - 91.537 -# Boot loader doesnt support boot protocol version 2.02. 91.538 -# If we have our code not at 0x90000, we need to move it there now. 91.539 -# We also then need to move the params behind it (commandline) 91.540 -# Because we would overwrite the code on the current IP, we move 91.541 -# it in two steps, jumping high after the first one. 91.542 - movw %cs, %ax 91.543 - cmpw $SETUPSEG, %ax 91.544 - je end_move_self 91.545 - 91.546 - cli # make sure we really have 91.547 - # interrupts disabled ! 91.548 - # because after this the stack 91.549 - # should not be used 91.550 - subw $DELTA_INITSEG, %ax # aka INITSEG 91.551 - movw %ss, %dx 91.552 - cmpw %ax, %dx 91.553 - jb move_self_1 91.554 - 91.555 - addw $INITSEG, %dx 91.556 - subw %ax, %dx # this will go into %ss after 91.557 - # the move 91.558 -move_self_1: 91.559 - movw %ax, %ds 91.560 - movw $INITSEG, %ax # real INITSEG 91.561 - movw %ax, %es 91.562 - movw %cs:setup_move_size, %cx 91.563 - std # we have to move up, so we use 91.564 - # direction down because the 91.565 - # areas may overlap 91.566 - movw %cx, %di 91.567 - decw %di 91.568 - movw %di, %si 91.569 - subw $move_self_here+0x200, %cx 91.570 - rep 91.571 - movsb 91.572 - ljmp $SETUPSEG, $move_self_here 91.573 - 91.574 -move_self_here: 91.575 - movw $move_self_here+0x200, %cx 91.576 - rep 91.577 - movsb 91.578 - movw $SETUPSEG, %ax 91.579 - movw %ax, %ds 91.580 - movw %dx, %ss 91.581 -end_move_self: # now we are at the right place 91.582 - 91.583 -# 91.584 -# Enable A20. This is at the very best an annoying procedure. 91.585 -# A20 code ported from SYSLINUX 1.52-1.63 by H. Peter Anvin. 91.586 -# AMD Elan bug fix by Robert Schwebel. 91.587 -# 91.588 - 91.589 -#if defined(CONFIG_X86_ELAN) 91.590 - movb $0x02, %al # alternate A20 gate 91.591 - outb %al, $0x92 # this works on SC410/SC520 91.592 -a20_elan_wait: 91.593 - call a20_test 91.594 - jz a20_elan_wait 91.595 - jmp a20_done 91.596 -#endif 91.597 - 91.598 - 91.599 -A20_TEST_LOOPS = 32 # Iterations per wait 91.600 -A20_ENABLE_LOOPS = 255 # Total loops to try 91.601 - 91.602 - 91.603 -#ifndef CONFIG_X86_VOYAGER 91.604 -a20_try_loop: 91.605 - 91.606 - # First, see if we are on a system with no A20 gate. 91.607 -a20_none: 91.608 - call a20_test 91.609 - jnz a20_done 91.610 - 91.611 - # Next, try the BIOS (INT 0x15, AX=0x2401) 91.612 -a20_bios: 91.613 - movw $0x2401, %ax 91.614 - pushfl # Be paranoid about flags 91.615 - int $0x15 91.616 - popfl 91.617 - 91.618 - call a20_test 91.619 - jnz a20_done 91.620 - 91.621 - # Try enabling A20 through the keyboard controller 91.622 -#endif /* CONFIG_X86_VOYAGER */ 91.623 -a20_kbc: 91.624 - call empty_8042 91.625 - 91.626 -#ifndef CONFIG_X86_VOYAGER 91.627 - call a20_test # Just in case the BIOS worked 91.628 - jnz a20_done # but had a delayed reaction. 91.629 -#endif 91.630 - 91.631 - movb $0xD1, %al # command write 91.632 - outb %al, $0x64 91.633 - call empty_8042 91.634 - 91.635 - movb $0xDF, %al # A20 on 91.636 - outb %al, $0x60 91.637 - call empty_8042 91.638 - 91.639 -#ifndef CONFIG_X86_VOYAGER 91.640 - # Wait until a20 really *is* enabled; it can take a fair amount of 91.641 - # time on certain systems; Toshiba Tecras are known to have this 91.642 - # problem. 91.643 -a20_kbc_wait: 91.644 - xorw %cx, %cx 91.645 -a20_kbc_wait_loop: 91.646 - call a20_test 91.647 - jnz a20_done 91.648 - loop a20_kbc_wait_loop 91.649 - 91.650 - # Final attempt: use "configuration port A" 91.651 -a20_fast: 91.652 - inb $0x92, %al # Configuration Port A 91.653 - orb $0x02, %al # "fast A20" version 91.654 - andb $0xFE, %al # don't accidentally reset 91.655 - outb %al, $0x92 91.656 - 91.657 - # Wait for configuration port A to take effect 91.658 -a20_fast_wait: 91.659 - xorw %cx, %cx 91.660 -a20_fast_wait_loop: 91.661 - call a20_test 91.662 - jnz a20_done 91.663 - loop a20_fast_wait_loop 91.664 - 91.665 - # A20 is still not responding. Try frobbing it again. 91.666 - # 91.667 - decb (a20_tries) 91.668 - jnz a20_try_loop 91.669 - 91.670 - movw $a20_err_msg, %si 91.671 - call prtstr 91.672 - 91.673 -a20_die: 91.674 - hlt 91.675 - jmp a20_die 91.676 - 91.677 -a20_tries: 91.678 - .byte A20_ENABLE_LOOPS 91.679 - 91.680 -a20_err_msg: 91.681 - .ascii "linux: fatal error: A20 gate not responding!" 91.682 - .byte 13, 10, 0 91.683 - 91.684 - # If we get here, all is good 91.685 -a20_done: 91.686 - 91.687 - 91.688 -#endif /* CONFIG_X86_VOYAGER */ 91.689 - 91.690 -/* Another print, to show protected mode and A20 are OK */ 91.691 - 91.692 - jmp mb_hello_mess2_end 91.693 -mb_hello_mess2: 91.694 - .string "pack " 91.695 -mb_hello_mess2_end: 91.696 - lea mb_hello_mess2, %si 91.697 - call prtstr 91.698 - 91.699 -# set up gdt and idt 91.700 -/* lidt idt_48 # load idt with 0,0 */ 91.701 -/* Multiboot kernels must set up their own IDT: leave this for now, 91.702 - * so we can print diagnostics */ 91.703 - 91.704 - xorl %eax, %eax # Compute gdt_base 91.705 - movw %ds, %ax # (Convert %ds:gdt to a linear ptr) 91.706 - shll $4, %eax 91.707 - addl $gdt, %eax 91.708 - movl %eax, (gdt_48+2) 91.709 - lgdt gdt_48 # load gdt with whatever is 91.710 - # appropriate 91.711 - 91.712 -# make sure any possible coprocessor is properly reset.. 91.713 - xorw %ax, %ax 91.714 - outb %al, $0xf0 91.715 - call delay 91.716 - 91.717 - outb %al, $0xf1 91.718 - call delay 91.719 - 91.720 - 91.721 -# well, that went ok, I hope. Now we mask all interrupts - the rest 91.722 -# is done in init_IRQ(). 91.723 - movb $0xFF, %al # mask all interrupts for now 91.724 - outb %al, $0xA1 91.725 - call delay 91.726 - 91.727 - movb $0xFB, %al # mask all irq's but irq2 which 91.728 - outb %al, $0x21 # is cascaded 91.729 - 91.730 -# Well, that certainly wasn't fun :-(. Hopefully it works, and we don't 91.731 -# need no steenking BIOS anyway (except for the initial loading :-). 91.732 -# The BIOS-routine wants lots of unnecessary data, and it's less 91.733 -# "interesting" anyway. This is how REAL programmers do it. 91.734 - 91.735 -/* Tailor the jump below so the target is the 32bit trampoline code */ 91.736 - 91.737 - xorl %eax, %eax # Calculate 91.738 - movw %cs, %ax # the linear 91.739 - shll $4, %eax # address of 91.740 - addl $trampoline32, %eax # %cs:trampoline32 91.741 - movl %eax, %cs:code32 # Stick it into the jmpi 91.742 - 91.743 - /* Load a 32-bit pointer to the entry address into %ecx */ 91.744 - xorl %ecx, %ecx # Calculate 91.745 - movw %cs, %cx # the linear 91.746 - shll $4, %ecx # address of 91.747 - addl $entry_address, %ecx # %cs:entry_address 91.748 - 91.749 -# Well, now's the time to actually move into protected mode. 91.750 - 91.751 - lea mb_ready_mess, %si 91.752 - call prtstr 91.753 - 91.754 -/* May as well load this IDT now */ 91.755 - lidt idt_48 91.756 - 91.757 - xorl %eax, %eax 91.758 - movw $1, %ax # protected mode (PE) bit 91.759 - lmsw %ax # This is it! 91.760 - jmp flush_instr 91.761 -flush_instr: 91.762 - 91.763 - /* Set up segment registers */ 91.764 - movw $__BOOT_DS, %dx 91.765 - movw %dx, %ds 91.766 - movw %dx, %es 91.767 - movw %dx, %fs 91.768 - movw %dx, %gs 91.769 - movw %dx, %ss 91.770 - 91.771 - /* Trampoline expects this in %eax */ 91.772 - movl %ecx, %eax 91.773 - 91.774 - /* Jump to the 32-bit trampoline */ 91.775 - 91.776 -# NOTE: For high loaded big kernels we need a 91.777 -# jmpi 0x100000,__BOOT_CS 91.778 -# 91.779 -# but we yet haven't reloaded the CS register, so the default size 91.780 -# of the target offset still is 16 bit. 91.781 -# However, using an operand prefix (0x66), the CPU will properly 91.782 -# take our 48 bit far pointer. (INTeL 80386 Programmer's Reference 91.783 -# Manual, Mixing 16-bit and 32-bit code, page 16-6) 91.784 - 91.785 - .byte 0x66, 0xea # prefix + jmpi-opcode 91.786 -code32: .long 0x1000 # will be set to trampoline32 91.787 - # by code above. 91.788 - .word __BOOT_CS 91.789 - 91.790 -# Here's a bunch of information about your current kernel.. 91.791 - 91.792 -kernel_version: .string "mbootpack changeling bzImage" 91.793 -mb_ready_mess: 91.794 - .ascii MBOOTPACK_VERSION_STRING 91.795 - .ascii "\r\n" 91.796 - .byte 0 91.797 - 91.798 -# This is the default real mode switch routine. 91.799 -# to be called just before protected mode transition 91.800 -default_switch: 91.801 - cli # no interrupts allowed ! 91.802 - movb $0x80, %al # disable NMI for bootup 91.803 - # sequence 91.804 - outb %al, $0x70 91.805 - lret 91.806 - 91.807 - 91.808 -#ifndef CONFIG_X86_VOYAGER 91.809 -# This routine tests whether or not A20 is enabled. If so, it 91.810 -# exits with zf = 0. 91.811 -# 91.812 -# The memory address used, 0x200, is the int $0x80 vector, which 91.813 -# should be safe. 91.814 - 91.815 -A20_TEST_ADDR = 4*0x80 91.816 - 91.817 -a20_test: 91.818 - pushw %cx 91.819 - pushw %ax 91.820 - xorw %cx, %cx 91.821 - movw %cx, %fs # Low memory 91.822 - decw %cx 91.823 - movw %cx, %gs # High memory area 91.824 - movw $A20_TEST_LOOPS, %cx 91.825 - movw %fs:(A20_TEST_ADDR), %ax 91.826 - pushw %ax 91.827 -a20_test_wait: 91.828 - incw %ax 91.829 - movw %ax, %fs:(A20_TEST_ADDR) 91.830 - call delay # Serialize and make delay constant 91.831 - cmpw %gs:(A20_TEST_ADDR+0x10), %ax 91.832 - loope a20_test_wait 91.833 - 91.834 - popw %fs:(A20_TEST_ADDR) 91.835 - popw %ax 91.836 - popw %cx 91.837 - ret 91.838 - 91.839 -#endif /* CONFIG_X86_VOYAGER */ 91.840 - 91.841 -# This routine checks that the keyboard command queue is empty 91.842 -# (after emptying the output buffers) 91.843 -# 91.844 -# Some machines have delusions that the keyboard buffer is always full 91.845 -# with no keyboard attached... 91.846 -# 91.847 -# If there is no keyboard controller, we will usually get 0xff 91.848 -# to all the reads. With each IO taking a microsecond and 91.849 -# a timeout of 100,000 iterations, this can take about half a 91.850 -# second ("delay" == outb to port 0x80). That should be ok, 91.851 -# and should also be plenty of time for a real keyboard controller 91.852 -# to empty. 91.853 -# 91.854 - 91.855 -empty_8042: 91.856 - pushl %ecx 91.857 - movl $100000, %ecx 91.858 - 91.859 -empty_8042_loop: 91.860 - decl %ecx 91.861 - jz empty_8042_end_loop 91.862 - 91.863 - call delay 91.864 - 91.865 - inb $0x64, %al # 8042 status port 91.866 - testb $1, %al # output buffer? 91.867 - jz no_output 91.868 - 91.869 - call delay 91.870 - inb $0x60, %al # read it 91.871 - jmp empty_8042_loop 91.872 - 91.873 -no_output: 91.874 - testb $2, %al # is input buffer full? 91.875 - jnz empty_8042_loop # yes - loop 91.876 -empty_8042_end_loop: 91.877 - popl %ecx 91.878 - ret 91.879 - 91.880 -# Read the cmos clock. Return the seconds in al 91.881 -gettime: 91.882 - pushw %cx 91.883 - movb $0x02, %ah 91.884 - int $0x1a 91.885 - movb %dh, %al # %dh contains the seconds 91.886 - andb $0x0f, %al 91.887 - movb %dh, %ah 91.888 - movb $0x04, %cl 91.889 - shrb %cl, %ah 91.890 - aad 91.891 - popw %cx 91.892 - ret 91.893 - 91.894 -# Delay is needed after doing I/O 91.895 -delay: 91.896 - outb %al,$0x80 91.897 - ret 91.898 - 91.899 -# Descriptor tables 91.900 -# 91.901 -# NOTE: The intel manual says gdt should be sixteen bytes aligned for 91.902 -# efficiency reasons. However, there are machines which are known not 91.903 -# to boot with misaligned GDTs, so alter this at your peril! If you alter 91.904 -# GDT_ENTRY_BOOT_CS (in asm/segment.h) remember to leave at least two 91.905 -# empty GDT entries (one for NULL and one reserved). 91.906 -# 91.907 -# NOTE: On some CPUs, the GDT must be 8 byte aligned. This is 91.908 -# true for the Voyager Quad CPU card which will not boot without 91.909 -# This directive. 16 byte aligment is recommended by intel. 91.910 -# 91.911 - 91.912 - 91.913 -/* The boot-time code segment is set at the jmpi above */ 91.914 -/* Dont change this without checking everything still matches */ 91.915 - 91.916 - .align 16 91.917 -gdt: 91.918 - .fill GDT_ENTRY_BOOT_CS,8,0 91.919 - 91.920 - .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb) 91.921 - .word 0 # base address = 0 91.922 - .word 0x9A00 # code read/exec 91.923 - .word 0x00CF # granularity = 4096, 386 91.924 - # (+5th nibble of limit) 91.925 - 91.926 - .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb) 91.927 - .word 0 # base address = 0 91.928 - .word 0x9200 # data read/write 91.929 - .word 0x00CF # granularity = 4096, 386 91.930 - # (+5th nibble of limit) 91.931 -gdt_end: 91.932 - .align 4 91.933 - 91.934 - .word 0 # alignment byte 91.935 -idt_48: 91.936 - .word 0 # idt limit = 0 91.937 - .word 0, 0 # idt base = 0L 91.938 - 91.939 - .word 0 # alignment byte 91.940 -gdt_48: 91.941 - .word gdt_end - gdt - 1 # gdt limit 91.942 - .word 0, 0 # gdt base (filled in later) 91.943 - 91.944 -# Include video setup & detection code 91.945 - 91.946 -/* #include "video.S" */ 91.947 - 91.948 -.code32 91.949 -trampoline32: 91.950 - /* Here, %eax = 32-bit pointer to entry_address */ 91.951 - 91.952 - /* Check if the bootloader gave us a (non-empty) command line */ 91.953 - movl -8(%eax), %ebx # cmd_line_ptr 91.954 - cmpl $0, %ebx 91.955 - je no_cmd_line 91.956 - cmpb $0, 0(%ebx) 91.957 - je no_cmd_line 91.958 - 91.959 - /* Find the MBI command line */ 91.960 - movl %eax, %ecx # &entry_address 91.961 - addl $(begtext-entry_address), %ecx # --> start of setup 91.962 - subl $0x9200, %ecx # --> reloc offset 91.963 - movl %ecx, %esi # (copy offset) 91.964 - movl %ecx, %ebx # (copy offset) 91.965 - addl 4(%eax), %ecx # --> current addr of MBI 91.966 - addl 16(%ecx), %ebx # --> cur. addr of MB cmdline 91.967 - 91.968 - /* Overwrite the built-in MBI kernel command line */ 91.969 - movl -8(%eax), %ecx 91.970 - movl $0, %edi 91.971 - 91.972 - /* Give the kernel a 'self' word, that linux doesn't get */ 91.973 - movw $0x202E, 0(%ebx) # '. ' 91.974 - addl $0x2, %ebx 91.975 - 91.976 -cmd_line_copy: 91.977 - movb (%ecx, %edi), %dl 91.978 - movb %dl, (%ebx, %edi) 91.979 - inc %edi 91.980 - cmp $CMD_LINE_SPACE-3, %edi 91.981 - je cmd_line_copy_end 91.982 - 91.983 - cmpb $0x0, %dl 91.984 - jne cmd_line_copy 91.985 -cmd_line_copy_end: 91.986 - movb $0x0, (%ebx, %edi) 91.987 - subl $0x2, %ebx 91.988 - 91.989 - /* Look for '--' in the kernel command line */ 91.990 -cmd_line_scan: 91.991 - inc %ebx 91.992 - cmpb $0x0, 0(%ebx) 91.993 - je no_cmd_line 91.994 - cmpl $0x202D2D20, 0(%ebx) # ' -- ' 91.995 - jne cmd_line_scan 91.996 - 91.997 - /* Found it: terminate kernel's command line */ 91.998 - movb $0x0, 0(%ebx) 91.999 - inc %ebx 91.1000 - /* Relocate address to where it will be moved to */ 91.1001 - subl %esi, %ebx 91.1002 - 91.1003 - /* Is there a module 0? */ 91.1004 - movl %esi, %ecx # Reloc offset 91.1005 - addl 4(%eax), %ecx # --> current addr of MBI 91.1006 - cmpl $0x0, 20(%ecx) # (check module count) 91.1007 - je no_cmd_line 91.1008 - /* Overwrite module 0's command line */ 91.1009 - movl %esi, %edx # Reloc offset 91.1010 - addl 24(%ecx), %edx # --> cur. add. of Module 0 91.1011 - movl %ebx, 8(%edx) # --> blat mod. 0's cmdline 91.1012 -no_cmd_line: 91.1013 - 91.1014 - 91.1015 - /* Relocate the MBI from after the setup code to its proper home 91.1016 - * between the MBI pointer and 0xa000 */ 91.1017 - movl %eax, %ecx # &entry_address 91.1018 - addl $(begtext-entry_address), %ecx # --> start of setup 91.1019 - subl $0x9200, %ecx # --> reloc offset 91.1020 - addl 4(%eax), %ecx # --> current addr of MBI 91.1021 - 91.1022 - movl $0xa000, %ebx # End of MBI 91.1023 - subl 4(%eax), %ebx # --> size of MBI 91.1024 - movl %ebx, %edi 91.1025 - 91.1026 - movl 4(%eax), %ebx # Destination of MBI 91.1027 - 91.1028 -mbi_copy: 91.1029 - dec %edi 91.1030 - movb (%ecx, %edi), %dl 91.1031 - movb %dl, (%ebx, %edi) 91.1032 - cmp $0x0, %edi 91.1033 - jne mbi_copy 91.1034 - 91.1035 - /* Copy memory size into MBI structure */ 91.1036 - movl 4(%eax), %ebx # MBI pointer 91.1037 - movl 8(%eax), %ecx # highmem_size 91.1038 - movl %ecx, 8(%ebx) # --> mbi.mem_upper 91.1039 - movl $0x280, %ecx 91.1040 - movl %ecx, 4(%ebx) # --> mbi.mem_lower 91.1041 - /* Set the MB_INFO_MEMORY bit */ 91.1042 - orl $1, 0(%ebx) 91.1043 - 91.1044 - /* Recover the MBI pointer into %ebx */ 91.1045 - movl 4(%eax), %ebx # MBI pointer 91.1046 - /* Extract the load address into %ecx */ 91.1047 - movl 0(%eax), %ecx 91.1048 - /* Let the kernel know we're a multiboot loader */ 91.1049 - movl $0x2BADB002, %eax 91.1050 - /* Jump to the kernel address supplied */ 91.1051 - jmp *%ecx 91.1052 - 91.1053 -# Setup signature -- must be last 91.1054 -setup_sig1: .word SIG1 91.1055 -setup_sig2: .word SIG2 91.1056 - 91.1057 -# After this point, there is some free space which is used by the video mode 91.1058 -# handling code to store the temporary mode table (not used by the kernel). 91.1059 - 91.1060 -modelist: 91.1061 - 91.1062 -.text 91.1063 -endtext: 91.1064 -.data 91.1065 -enddata: 91.1066 -.bss 91.1067 -endbss:
92.1 --- a/tools/misc/miniterm/Makefile Sun Oct 22 14:39:15 2006 -0600 92.2 +++ b/tools/misc/miniterm/Makefile Sun Oct 22 15:23:52 2006 -0600 92.3 @@ -1,10 +1,6 @@ 92.4 XEN_ROOT:=../../.. 92.5 include $(XEN_ROOT)/tools/Rules.mk 92.6 92.7 -INSTALL = install 92.8 -INSTALL_PROG = $(INSTALL) -m0755 92.9 -INSTALL_DIR = $(INSTALL) -d -m0755 92.10 - 92.11 TARGET = miniterm 92.12 92.13 .PHONY: all
93.1 --- a/tools/misc/xend Sun Oct 22 14:39:15 2006 -0600 93.2 +++ b/tools/misc/xend Sun Oct 22 15:23:52 2006 -0600 93.3 @@ -19,6 +19,9 @@ 93.4 93.5 The daemon should reconnect to device control interfaces 93.6 and recover its state when restarted. 93.7 + 93.8 + On Solaris, the daemons are SMF managed, and you should not attempt 93.9 + to start xend by hand. 93.10 """ 93.11 import os 93.12 import os.path 93.13 @@ -108,9 +111,10 @@ def main(): 93.14 if not sys.argv[1:]: 93.15 print 'usage: %s {start|stop|restart}' % sys.argv[0] 93.16 elif sys.argv[1] == 'start': 93.17 - start_xenstored() 93.18 - start_consoled() 93.19 - start_blktapctrl() 93.20 + if os.uname()[0] != "SunOS": 93.21 + start_xenstored() 93.22 + start_consoled() 93.23 + start_blktapctrl() 93.24 return daemon.start() 93.25 elif sys.argv[1] == 'trace_start': 93.26 start_xenstored()
94.1 --- a/tools/pygrub/Makefile Sun Oct 22 14:39:15 2006 -0600 94.2 +++ b/tools/pygrub/Makefile Sun Oct 22 15:23:52 2006 -0600 94.3 @@ -6,16 +6,16 @@ include $(XEN_ROOT)/tools/Rules.mk 94.4 all: build 94.5 .PHONY: build 94.6 build: 94.7 - CFLAGS="$(CFLAGS)" python setup.py build 94.8 + CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py build 94.9 94.10 .PHONY: install 94.11 ifndef XEN_PYTHON_NATIVE_INSTALL 94.12 install: all 94.13 - CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --prefix="" 94.14 + CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --prefix="" 94.15 $(INSTALL_DIR) -p $(DESTDIR)/var/lib/xen 94.16 else 94.17 install: all 94.18 - CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" 94.19 + CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" 94.20 $(INSTALL_DIR) -p $(DESTDIR)/var/lib/xen 94.21 endif 94.22
95.1 --- a/tools/python/Makefile Sun Oct 22 14:39:15 2006 -0600 95.2 +++ b/tools/python/Makefile Sun Oct 22 15:23:52 2006 -0600 95.3 @@ -6,15 +6,15 @@ all: build 95.4 95.5 .PHONY: build 95.6 build: 95.7 - CFLAGS="$(CFLAGS)" python setup.py build 95.8 + CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py build 95.9 95.10 .PHONY: install 95.11 ifndef XEN_PYTHON_NATIVE_INSTALL 95.12 install: all 95.13 - CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --prefix="" --force 95.14 + CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --prefix="" --force 95.15 else 95.16 install: all 95.17 - CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" --force 95.18 + CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" --force 95.19 endif 95.20 95.21 .PHONY: test
96.1 --- a/tools/python/xen/util/auxbin.py Sun Oct 22 14:39:15 2006 -0600 96.2 +++ b/tools/python/xen/util/auxbin.py Sun Oct 22 15:23:52 2006 -0600 96.3 @@ -21,7 +21,7 @@ LIB_64 = "/usr/lib64" 96.4 LIB_BIN_SUFFIX = "xen/bin" 96.5 96.6 ## The architectures on which the LIB_64 directory is used. This 96.7 -# deliberately excludes ia64 and ppc64. 96.8 +# deliberately excludes ia64 and ppc64, and Solaris. 96.9 LIB_64_ARCHS = [ 'x86_64', 's390x', 'sparc64'] 96.10 96.11
97.1 --- a/tools/python/xen/util/security.py Sun Oct 22 14:39:15 2006 -0600 97.2 +++ b/tools/python/xen/util/security.py Sun Oct 22 15:23:52 2006 -0600 97.3 @@ -31,6 +31,7 @@ from xen.util import dictio 97.4 policy_dir_prefix = "/etc/xen/acm-security/policies" 97.5 res_label_filename = policy_dir_prefix + "/resource_labels" 97.6 boot_filename = "/boot/grub/menu.lst" 97.7 +altboot_filename = "/boot/grub/grub.conf" 97.8 xensec_xml2bin = "/usr/sbin/xensec_xml2bin" 97.9 xensec_tool = "/usr/sbin/xensec_tool" 97.10 97.11 @@ -596,12 +597,34 @@ def get_res_security_details(resource): 97.12 return (label, ssidref, policy) 97.13 97.14 97.15 +def unify_resname(resource): 97.16 + """Makes all resource locations absolute. In case of physical 97.17 + resources, '/dev/' is added to local file names""" 97.18 + 97.19 + # sanity check on resource name 97.20 + (type, resfile) = resource.split(":") 97.21 + if type == "phy": 97.22 + if not resfile.startswith("/"): 97.23 + resfile = "/dev/" + resfile 97.24 + 97.25 + #file: resources must specified with absolute path 97.26 + if (not resfile.startswith("/")) or (not os.path.exists(resfile)): 97.27 + err("Invalid resource.") 97.28 + 97.29 + # from here on absolute file names with resources 97.30 + resource = type + ":" + resfile 97.31 + return resource 97.32 + 97.33 + 97.34 def res_security_check(resource, domain_label): 97.35 """Checks if the given resource can be used by the given domain 97.36 label. Returns 1 if the resource can be used, otherwise 0. 97.37 """ 97.38 rtnval = 1 97.39 97.40 + #build canonical resource name 97.41 + resource = unify_resname(resource) 97.42 + 97.43 # if security is on, ask the hypervisor for a decision 97.44 if on(): 97.45 (label, ssidref, policy) = get_res_security_details(resource)
98.1 --- a/tools/python/xen/xend/XendDomainInfo.py Sun Oct 22 14:39:15 2006 -0600 98.2 +++ b/tools/python/xen/xend/XendDomainInfo.py Sun Oct 22 15:23:52 2006 -0600 98.3 @@ -392,6 +392,8 @@ def parseConfig(config): 98.4 log.warn("Ignoring malformed and deprecated config option " 98.5 "restart = %s", restart) 98.6 98.7 + result['start_time'] = get_cfg('start_time', float) 98.8 + 98.9 log.debug("parseConfig: result is %s", result) 98.10 return result 98.11
99.1 --- a/tools/python/xen/xend/XendRoot.py Sun Oct 22 14:39:15 2006 -0600 99.2 +++ b/tools/python/xen/xend/XendRoot.py Sun Oct 22 15:23:52 2006 -0600 99.3 @@ -30,6 +30,7 @@ import os.path 99.4 import string 99.5 import sys 99.6 99.7 +import osdep 99.8 import XendLogging 99.9 from XendError import XendError 99.10 99.11 @@ -46,10 +47,10 @@ class XendRoot: 99.12 config_var = "XEND_CONFIG" 99.13 99.14 """Where network control scripts live.""" 99.15 - network_script_dir = "/etc/xen/scripts" 99.16 + network_script_dir = osdep.scripts_dir 99.17 99.18 """Where block control scripts live.""" 99.19 - block_script_dir = "/etc/xen/scripts" 99.20 + block_script_dir = osdep.scripts_dir 99.21 99.22 """Default path to the log file. """ 99.23 logfile_default = "/var/log/xen/xend.log" 99.24 @@ -96,6 +97,8 @@ class XendRoot: 99.25 99.26 dom0_vcpus_default = '0' 99.27 99.28 + vncpasswd_default = None 99.29 + 99.30 """Default interface to listen for VNC connections on""" 99.31 xend_vnc_listen_default = '127.0.0.1' 99.32 99.33 @@ -278,6 +281,10 @@ class XendRoot: 99.34 def get_vnclisten_address(self): 99.35 return self.get_config_value('vnc-listen', self.xend_vnc_listen_default) 99.36 99.37 + def get_vncpasswd_default(self): 99.38 + return self.get_config_value('vncpasswd', 99.39 + self.vncpasswd_default) 99.40 + 99.41 def instance(): 99.42 """Get an instance of XendRoot. 99.43 Use this instead of the constructor.
100.1 --- a/tools/python/xen/xend/arch.py Sun Oct 22 14:39:15 2006 -0600 100.2 +++ b/tools/python/xen/xend/arch.py Sun Oct 22 15:23:52 2006 -0600 100.3 @@ -25,6 +25,7 @@ import os 100.4 "i586": "x86", 100.5 "i686": "x86", 100.6 "x86_64": "x86", 100.7 + "i86pc": "x86", 100.8 "ia64": "ia64", 100.9 "ppc": "powerpc", 100.10 "ppc64": "powerpc",
101.1 --- a/tools/python/xen/xend/image.py Sun Oct 22 14:39:15 2006 -0600 101.2 +++ b/tools/python/xen/xend/image.py Sun Oct 22 15:23:52 2006 -0600 101.3 @@ -20,6 +20,7 @@ 101.4 import os, string 101.5 import re 101.6 import math 101.7 +import signal 101.8 101.9 import xen.lowlevel.xc 101.10 from xen.xend import sxp 101.11 @@ -312,6 +313,11 @@ class HVMImageHandler(ImageHandler): 101.12 if v: 101.13 ret.append("-%s" % a) 101.14 ret.append("%s" % v) 101.15 + 101.16 + if a in ['fda', 'fdb' ]: 101.17 + if v: 101.18 + if not os.path.isfile(v): 101.19 + raise VmError("Floppy file %s does not exist." % v) 101.20 log.debug("args: %s, val: %s" % (a,v)) 101.21 101.22 # Handle disk/network related options 101.23 @@ -349,23 +355,49 @@ class HVMImageHandler(ImageHandler): 101.24 sdl = sxp.child_value(config, 'sdl') 101.25 ret = [] 101.26 nographic = sxp.child_value(config, 'nographic') 101.27 + 101.28 + # get password from VM config (if password omitted, None) 101.29 + vncpasswd_vmconfig = sxp.child_value(config, 'vncpasswd') 101.30 + 101.31 if nographic: 101.32 ret.append('-nographic') 101.33 + # remove password 101.34 + if vncpasswd_vmconfig: 101.35 + config.remove(['vncpasswd', vncpasswd_vmconfig]) 101.36 return ret 101.37 + 101.38 if vnc: 101.39 vncdisplay = sxp.child_value(config, 'vncdisplay', 101.40 int(self.vm.getDomid())) 101.41 + 101.42 vncunused = sxp.child_value(config, 'vncunused') 101.43 if vncunused: 101.44 ret += ['-vncunused'] 101.45 else: 101.46 ret += ['-vnc', '%d' % vncdisplay] 101.47 + 101.48 ret += ['-k', 'en-us'] 101.49 + 101.50 vnclisten = sxp.child_value(config, 'vnclisten') 101.51 if not(vnclisten): 101.52 - vnclisten = xen.xend.XendRoot.instance().get_vnclisten_address() 101.53 + vnclisten = (xen.xend.XendRoot.instance(). 101.54 + get_vnclisten_address()) 101.55 if vnclisten: 101.56 ret += ['-vnclisten', vnclisten] 101.57 + 101.58 + vncpasswd = vncpasswd_vmconfig 101.59 + if vncpasswd is None: 101.60 + vncpasswd = (xen.xend.XendRoot.instance(). 101.61 + get_vncpasswd_default()) 101.62 + if vncpasswd is None: 101.63 + raise VmError('vncpasswd is not set up in ' + 101.64 + 'VMconfig and xend-config.') 101.65 + if vncpasswd != '': 101.66 + self.vm.storeVm("vncpasswd", vncpasswd) 101.67 + 101.68 + # remove password 101.69 + config.remove(['vncpasswd', vncpasswd_vmconfig]) 101.70 + 101.71 return ret 101.72 101.73 def createDeviceModel(self): 101.74 @@ -390,7 +422,6 @@ class HVMImageHandler(ImageHandler): 101.75 101.76 def destroy(self): 101.77 self.unregister_shutdown_watch(); 101.78 - import signal 101.79 if not self.pid: 101.80 return 101.81 os.kill(self.pid, signal.SIGKILL)
102.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 102.2 +++ b/tools/python/xen/xend/osdep.py Sun Oct 22 15:23:52 2006 -0600 102.3 @@ -0,0 +1,36 @@ 102.4 +#!/usr/bin/env python 102.5 +# 102.6 +# This library is free software; you can redistribute it and/or 102.7 +# modify it under the terms of version 2.1 of the GNU Lesser General Public 102.8 +# License as published by the Free Software Foundation. 102.9 +# 102.10 +# This library is distributed in the hope that it will be useful, 102.11 +# but WITHOUT ANY WARRANTY; without even the implied warranty of 102.12 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 102.13 +# Lesser General Public License for more details. 102.14 +# 102.15 +# You should have received a copy of the GNU Lesser General Public 102.16 +# License along with this library; if not, write to the Free Software 102.17 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 102.18 +# 102.19 + 102.20 +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 102.21 +# Use is subject to license terms. 102.22 + 102.23 +import os 102.24 + 102.25 +_scripts_dir = { 102.26 + "Linux": "/etc/xen/scripts", 102.27 + "SunOS": "/usr/lib/xen/scripts", 102.28 +} 102.29 + 102.30 +_xend_autorestart = { 102.31 + "Linux": True, 102.32 + "SunOS": False, 102.33 +} 102.34 + 102.35 +def _get(var, default=None): 102.36 + return var.get(os.uname()[0], default) 102.37 + 102.38 +scripts_dir = _get(_scripts_dir, "/etc/xen/scripts") 102.39 +xend_autorestart = _get(_xend_autorestart)
103.1 --- a/tools/python/xen/xend/server/SrvDaemon.py Sun Oct 22 14:39:15 2006 -0600 103.2 +++ b/tools/python/xen/xend/server/SrvDaemon.py Sun Oct 22 15:23:52 2006 -0600 103.3 @@ -17,6 +17,7 @@ import traceback 103.4 import xen.lowlevel.xc 103.5 103.6 from xen.xend.XendLogging import log 103.7 +from xen.xend import osdep 103.8 103.9 import relocate 103.10 import SrvServer 103.11 @@ -168,8 +169,14 @@ class Daemon: 103.12 # ready to receive requests. All subsequent restarts we don't 103.13 # want this behaviour, or the pipe will eventually fill up, so 103.14 # we just pass None into run in subsequent cases (by clearing w 103.15 - # in the parent of the first fork). 103.16 + # in the parent of the first fork). On some operating systems, 103.17 + # restart is managed externally, so we won't fork, and just exit. 103.18 while True: 103.19 + 103.20 + if not osdep.xend_autorestart: 103.21 + self.run(os.fdopen(w, 'w')) 103.22 + break 103.23 + 103.24 pid = self.fork_pid() 103.25 if pid: 103.26 if w is not None:
104.1 --- a/tools/python/xen/xend/server/blkif.py Sun Oct 22 14:39:15 2006 -0600 104.2 +++ b/tools/python/xen/xend/server/blkif.py Sun Oct 22 15:23:52 2006 -0600 104.3 @@ -81,6 +81,9 @@ class BlkifController(DevController): 104.4 'acm_policy' : policy}) 104.5 104.6 devid = blkif.blkdev_name_to_number(dev) 104.7 + if not devid: 104.8 + raise VmError('Unable to find number for device (%s)' % (dev)) 104.9 + 104.10 front = { 'virtual-device' : "%i" % devid, 104.11 'device-type' : dev_type 104.12 }
105.1 --- a/tools/python/xen/xm/addlabel.py Sun Oct 22 14:39:15 2006 -0600 105.2 +++ b/tools/python/xen/xm/addlabel.py Sun Oct 22 15:23:52 2006 -0600 105.3 @@ -72,13 +72,8 @@ def add_resource_label(label, resource, 105.4 # sanity check: make sure this label can be instantiated later on 105.5 ssidref = security.label2ssidref(label, policyref, 'res') 105.6 105.7 - # sanity check on resource name 105.8 - (type, file) = resource.split(":") 105.9 - if type == "phy": 105.10 - file = "/dev/" + file 105.11 - if not os.path.exists(file): 105.12 - print "Invalid resource '"+resource+"'" 105.13 - return 105.14 + #build canonical resource name 105.15 + resource = security.unify_resname(resource) 105.16 105.17 # see if this resource is already in the file 105.18 access_control = {}
106.1 --- a/tools/python/xen/xm/cfgbootpolicy.py Sun Oct 22 14:39:15 2006 -0600 106.2 +++ b/tools/python/xen/xm/cfgbootpolicy.py Sun Oct 22 15:23:52 2006 -0600 106.3 @@ -14,6 +14,7 @@ 106.4 #============================================================================ 106.5 # Copyright (C) 2006 International Business Machines Corp. 106.6 # Author: Reiner Sailer <sailer@us.ibm.com> 106.7 +# Contributions: Stefan Berger <stefanb@us.ibm.com> 106.8 #============================================================================ 106.9 """Configuring a security policy into the boot configuration 106.10 """ 106.11 @@ -24,67 +25,60 @@ import tempfile 106.12 import os, stat 106.13 import shutil 106.14 import string 106.15 -from xen.util.security import ACMError, err 106.16 -from xen.util.security import policy_dir_prefix, boot_filename, xen_title_re 106.17 -from xen.util.security import any_title_re, xen_kernel_re, kernel_ver_re, any_module_re 106.18 +import re 106.19 +from xen.util.security import err 106.20 +from xen.util.security import policy_dir_prefix, xen_title_re 106.21 +from xen.util.security import boot_filename, altboot_filename 106.22 +from xen.util.security import any_title_re, xen_kernel_re, any_module_re 106.23 from xen.util.security import empty_line_re, binary_name_re, policy_name_re 106.24 from xen.xm.opts import OptionError 106.25 106.26 def help(): 106.27 return """ 106.28 - Adds a 'module' line to the Xen grub.conf entry 106.29 - so that xen boots into a specific access control 106.30 - policy. If kernelversion is not given, then this 106.31 - script tries to determine it by looking for a grub 106.32 - entry with a line kernel xen.* If there are multiple 106.33 - Xen entries, then it must be called with an explicit 106.34 - version (it will fail otherwise).\n""" 106.35 - 106.36 -def determine_kernelversion(user_specified): 106.37 - within_xen_title = 0 106.38 - within_xen_entry = 0 106.39 - version_list = [] 106.40 - guess_version = None 106.41 + Adds a 'module' line to the Xen grub configuration file entry 106.42 + so that Xen boots with a specific access control policy. If 106.43 + kernelversion is not given, then this script tries to determine 106.44 + it by looking for a title starting with \"XEN\". If there are 106.45 + multiple entries matching, then it must be called with the unique 106.46 + beginning of the title's name.\n""" 106.47 106.48 - grub_fd = open(boot_filename) 106.49 - for line in grub_fd: 106.50 - if xen_title_re.match(line): 106.51 - within_xen_title = 1 106.52 - elif within_xen_title and xen_kernel_re.match(line): 106.53 - within_xen_entry = 1 106.54 - elif within_xen_title and within_xen_entry and kernel_ver_re.match(line): 106.55 - for i in line.split(): 106.56 - if (i.find("vmlinuz-") >= 0): 106.57 - # skip start until "vmlinuz-" 106.58 - guess_version = i[i.find("vmlinuz-") + len("vmlinuz-"):] 106.59 - if user_specified: 106.60 - if (guess_version == user_specified): 106.61 - version_list.append(guess_version) 106.62 - else: 106.63 - version_list.append(guess_version) 106.64 - elif len(line.split()) > 0: 106.65 - if line.split()[0] == "title": 106.66 - within_xen_title = 0 106.67 - within_xen_entry = 0 106.68 - if len(version_list) > 1: 106.69 - err("Cannot decide between entries for kernels %s" % version_list) 106.70 - elif len(version_list) == 0: 106.71 - err("Cannot find a boot entry candidate (please create a Xen boot entry first).") 106.72 +def strip_title(line): 106.73 + """ 106.74 + strips whitespace left and right and cuts 'title' 106.75 + """ 106.76 + s_title = string.strip(line) 106.77 + pos = string.index(s_title, "title") 106.78 + if pos >= 0: 106.79 + return s_title[pos+6:] 106.80 else: 106.81 - return version_list[0] 106.82 + return s_title 106.83 106.84 106.85 - 106.86 -def insert_policy(boot_file, kernel_version, policy_name): 106.87 +def insert_policy(boot_file, alt_boot_file, user_title, policy_name): 106.88 """ 106.89 inserts policy binary file as last line of the grub entry 106.90 matching the kernel_version version 106.91 """ 106.92 + if user_title: 106.93 + #replace "(" by "\(" and ")" by "\)" for matching 106.94 + user_title = string.replace(user_title, "(", "\(") 106.95 + user_title = string.replace(user_title, ")", "\)") 106.96 + user_title_re = re.compile("\s*title\s+.*%s" \ 106.97 + % user_title, re.IGNORECASE) 106.98 + else: 106.99 + user_title_re = xen_title_re 106.100 + 106.101 within_xen_title = 0 106.102 within_xen_entry = 0 106.103 insert_at_end_of_entry = 0 106.104 path_prefix = '' 106.105 + this_title = '' 106.106 + extended_titles = [] 106.107 (tmp_fd, tmp_grub) = tempfile.mkstemp() 106.108 + #First check whether menu.lst exists 106.109 + if not os.path.isfile(boot_file): 106.110 + #take alternate boot file (grub.conf) instead 106.111 + boot_file = alt_boot_file 106.112 #follow symlink since menue.lst might be linked to grub.conf 106.113 if stat.S_ISLNK(os.lstat(boot_file)[stat.ST_MODE]): 106.114 new_name = os.readlink(boot_file) 106.115 @@ -95,30 +89,33 @@ def insert_policy(boot_file, kernel_vers 106.116 path[len(path)-1] = new_name 106.117 boot_file = '/'.join(path) 106.118 if not os.path.exists(boot_file): 106.119 - err("Boot file \'" + boot_file + "\' not found.") 106.120 + err("Boot file \'%s\' not found." % boot_file) 106.121 grub_fd = open(boot_file) 106.122 for line in grub_fd: 106.123 - if xen_title_re.match(line): 106.124 + if user_title_re.match(line): 106.125 + this_title = strip_title(line) 106.126 within_xen_title = 1 106.127 elif within_xen_title and xen_kernel_re.match(line): 106.128 - within_xen_entry = 1 106.129 - elif within_xen_title and within_xen_entry and kernel_ver_re.match(line): 106.130 - for i in line.split(): 106.131 - if (i.find("vmlinuz-") >= 0): 106.132 - if kernel_version == i[i.find("vmlinuz-") + len("vmlinuz-"):]: 106.133 - insert_at_end_of_entry = 1 106.134 - path_prefix = i[0:i.find("vmlinuz-")] 106.135 + insert_at_end_of_entry = 1 106.136 + #use prefix from xen.gz path for policy 106.137 + path_prefix = line.split()[1] 106.138 + idx = path_prefix.rfind('/') 106.139 + if idx >= 0: 106.140 + path_prefix = path_prefix[0:idx+1] 106.141 + else: 106.142 + path_prefix = '' 106.143 elif any_module_re.match(line) and insert_at_end_of_entry: 106.144 if binary_name_re.match(line): 106.145 #delete existing policy module line 106.146 line='' 106.147 elif any_title_re.match(line): 106.148 within_xen_title = 0 106.149 - within_xen_entry = 0 106.150 106.151 - if (empty_line_re.match(line) or any_title_re.match(line)) and insert_at_end_of_entry: 106.152 + if (empty_line_re.match(line) or any_title_re.match(line)) and \ 106.153 + insert_at_end_of_entry: 106.154 #newline or new title: we insert the policy module line here 106.155 os.write(tmp_fd, "\tmodule " + path_prefix + policy_name + ".bin\n") 106.156 + extended_titles.append(this_title) 106.157 insert_at_end_of_entry = 0 106.158 #write the line that was read (except potential existing policy entry) 106.159 os.write(tmp_fd, line) 106.160 @@ -126,27 +123,36 @@ def insert_policy(boot_file, kernel_vers 106.161 if insert_at_end_of_entry: 106.162 #last entry, no empty line at end of file 106.163 os.write(tmp_fd, "\tmodule " + path_prefix + policy_name + ".bin\n") 106.164 + extended_titles.append(this_title) 106.165 106.166 - #temp file might be destroyed when closing it, first copy ... 106.167 + #if more than one entry was changed, abort 106.168 + if len(extended_titles) > 1: 106.169 + err("Following boot entries matched: %s. \nPlease specify " 106.170 + "unique part of the boot title." % extended_titles) 106.171 + if len(extended_titles) == 0: 106.172 + err("Boot entry not found. Please specify unique part " 106.173 + "of the boot title.") 106.174 + 106.175 + #temp file might be destroyed when closing it, first copy it 106.176 shutil.move(boot_file, boot_file+"_save") 106.177 shutil.copyfile(tmp_grub, boot_file) 106.178 os.close(tmp_fd) 106.179 - #temp file did not disappear on my system ... 106.180 + #sometimes the temp file does not disappear 106.181 try: 106.182 os.remove(tmp_grub) 106.183 except: 106.184 pass 106.185 - 106.186 + return extended_titles[0] 106.187 106.188 106.189 def main(argv): 106.190 user_kver = None 106.191 - policy = None 106.192 + user_title = None 106.193 if len(argv) == 2: 106.194 policy = argv[1] 106.195 elif len(argv) == 3: 106.196 policy = argv[1] 106.197 - user_kver = argv[2] 106.198 + user_title = argv[2] 106.199 else: 106.200 raise OptionError('Invalid number of arguments') 106.201 106.202 @@ -167,9 +173,10 @@ def main(argv): 106.203 dst_binary_policy_file = "/boot/" + policy + ".bin" 106.204 shutil.copyfile(src_binary_policy_file, dst_binary_policy_file) 106.205 106.206 - kernel_version = determine_kernelversion(user_kver) 106.207 - insert_policy(boot_filename, kernel_version, policy) 106.208 - print "Boot entry created and \'%s\' copied to /boot" % (policy + ".bin") 106.209 + entryname = insert_policy(boot_filename, altboot_filename, 106.210 + user_title, policy) 106.211 + print "Boot entry '%s' extended and \'%s\' copied to /boot" \ 106.212 + % (entryname, policy + ".bin") 106.213 106.214 if __name__ == '__main__': 106.215 try: 106.216 @@ -177,4 +184,3 @@ if __name__ == '__main__': 106.217 except Exception, e: 106.218 sys.stderr.write('Error: ' + str(e) + '\n') 106.219 sys.exit(-1) 106.220 -
107.1 --- a/tools/python/xen/xm/create.py Sun Oct 22 14:39:15 2006 -0600 107.2 +++ b/tools/python/xen/xm/create.py Sun Oct 22 15:23:52 2006 -0600 107.3 @@ -104,6 +104,10 @@ gopts.opt('console_autoconnect', short=' 107.4 fn=set_true, default=0, 107.5 use="Connect to the console after the domain is created.") 107.6 107.7 +gopts.var('vncpasswd', val='NAME', 107.8 + fn=set_value, default=None, 107.9 + use="Password for VNC console on HVM domain.") 107.10 + 107.11 gopts.var('vncviewer', val='no|yes', 107.12 fn=set_bool, default=None, 107.13 use="Spawn a vncviewer listening for a vnc server in the domain.\n" 107.14 @@ -643,6 +647,7 @@ def configure_hvm(config_image, vals): 107.15 for a in args: 107.16 if (vals.__dict__[a]): 107.17 config_image.append([a, vals.__dict__[a]]) 107.18 + config_image.append(['vncpasswd', vals.vncpasswd]) 107.19 107.20 def run_bootloader(vals, config_image): 107.21 if not os.access(vals.bootloader, os.X_OK):
108.1 --- a/tools/python/xen/xm/getlabel.py Sun Oct 22 14:39:15 2006 -0600 108.2 +++ b/tools/python/xen/xm/getlabel.py Sun Oct 22 15:23:52 2006 -0600 108.3 @@ -33,6 +33,9 @@ def help(): 108.4 def get_resource_label(resource): 108.5 """Gets the resource label 108.6 """ 108.7 + #build canonical resource name 108.8 + resource = security.unify_resname(resource) 108.9 + 108.10 # read in the resource file 108.11 file = security.res_label_filename 108.12 try:
109.1 --- a/tools/python/xen/xm/rmlabel.py Sun Oct 22 14:39:15 2006 -0600 109.2 +++ b/tools/python/xen/xm/rmlabel.py Sun Oct 22 15:23:52 2006 -0600 109.3 @@ -37,6 +37,9 @@ def help(): 109.4 def rm_resource_label(resource): 109.5 """Removes a resource label from the global resource label file. 109.6 """ 109.7 + #build canonical resource name 109.8 + resource = security.unify_resname(resource) 109.9 + 109.10 # read in the resource file 109.11 file = security.res_label_filename 109.12 try:
110.1 --- a/tools/security/example.txt Sun Oct 22 14:39:15 2006 -0600 110.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 110.3 @@ -1,376 +0,0 @@ 110.4 -## 110.5 -# example.txt <description to the xen access control architecture> 110.6 -# 110.7 -# Author: 110.8 -# Reiner Sailer 08/15/2005 <sailer@watson.ibm.com> 110.9 -# 04/07/2006 update to using labels instead of ssidref 110.10 -# 110.11 -# 110.12 -# This file introduces into the tools to manage policies 110.13 -# and to label domains and resources. 110.14 -## 110.15 - 110.16 -We will show how to install and use the example one of the client_v1 110.17 -policies. Other policies work similarly. Feedback welcome! 110.18 - 110.19 - 110.20 - 110.21 -1. Using xm tools to translate example.chwall_ste.client_v1 policy: 110.22 -=================================================================== 110.23 - 110.24 -#xm makepolicy example.chwall_ste.client_v1 110.25 - 110.26 -By default, the tool looks in directory /etc/xen/acm-security/policies 110.27 -for a directory that matches the policy name 110.28 -(here:example/chwall_ste/client_v1-security_policy.xml) to find the 110.29 -policy files. The '-d' option can be used to override the default 110.30 -/etc/xen/acm-security/policies policy-root directory. 110.31 - 110.32 -The default policy directory structure under /etc/xen/acm-security (and 110.33 -the Xen security tool build directory - tools/security) looks like: 110.34 - 110.35 -policies 110.36 -|-- security_policy.xsd 110.37 -|-- example 110.38 - |-- chwall 110.39 - | |-- client_v1-security_policy.xml 110.40 - | 110.41 - |-- chwall_ste 110.42 - | |-- client_v1-security_policy.xml 110.43 - | 110.44 - |-- ste 110.45 - |-- client_v1-security_policy.xml 110.46 - 110.47 -The security_policy.xsd file contains the schema against which the 110.48 -policy files must validate during translation. 110.49 - 110.50 -The policy files, ending in -security_policy.xml, define the policies, 110.51 -the types known to the policies, and the label definitions that group 110.52 -types together and make them easier to use for users. 110.53 - 110.54 -After executing the above 'xm makepolicy' command, you will find 2 new 110.55 -files in the /etc/xen/acm-security/policies/example/chwall_ste 110.56 -sub-directory: 110.57 - 110.58 - client_v1.map ... this file includes the mapping 110.59 - of names from the xml files into their binary code representation. 110.60 - 110.61 - client_v1.bin ... this is the binary policy file, the result of 110.62 - parsing the xml files and using the mapping to create a binary 110.63 - version that can be loaded into the hypervisor. 110.64 - 110.65 - 110.66 - 110.67 -2. Loading and activating the policy: 110.68 -===================================== 110.69 - 110.70 -We assume that xen is already configured for security; 110.71 -please refer to install.txt for instructions. 110.72 - 110.73 -To activate the policy from the command line: 110.74 - 110.75 -# xm loadpolicy example.chwall_ste.client_v1 110.76 - 110.77 -See install.txt for how to install a policy at boot time. This the 110.78 -recommended default. You can only load a policy if the currently 110.79 -enforced policy is "DEFAULT", a minimal startup policy, or if the 110.80 -currently enforced policy has the same name as the new one. Support 110.81 -for dynamic policy changes at run-time are a current working item. 110.82 - 110.83 - 110.84 -3. Labeling domains: 110.85 -==================== 110.86 - 110.87 -a) Labeling Domain0: 110.88 - 110.89 -The chwall_ste-security_label_template.xml file includes an attribute 110.90 -"bootstrap", which is set to the label name that will be assigned to 110.91 -Dom0 (this label will be mapped to ssidref 1/1, the default for Dom0). 110.92 - 110.93 -b) Labeling User Domains (domains started from dom0 using xm commands): 110.94 - 110.95 -We distinguish two kinds of labels: a) VM labels (for domains) and RES 110.96 -Labels (for resources). We focus here on VM labels. Resource labels 110.97 -will be supported later. 110.98 - 110.99 -To list all available domain labels of a policy, use: 110.100 - #xm labels example.chwall_ste.client_v1 110.101 - 110.102 -To list all available labels including resource labels (their support 110.103 -is current work), use: 110.104 - 110.105 - #xm labels example.chwall_ste.client_v1 type=any 110.106 - 110.107 -The policy parameter is optional. The currently enforced hypervisor 110.108 -policy is used by default. 110.109 - 110.110 -If you would like to assign the dom_HomeBanking label to one of your user domains, 110.111 -look at the hypothetical domain configuration contained in /etc/xen/homebanking.xm: 110.112 - 110.113 - #------FOR HOME/ONLINE BANKING--------- 110.114 - kernel = "/boot/vmlinuz-2.6.16-xen" 110.115 - ramdisk="/boot/U1_ramdisk.img" 110.116 - memory = 164 110.117 - name = "homebanking" 110.118 - vif=[''] 110.119 - dhcp = "dhcp" 110.120 - #------------------------- 110.121 - 110.122 -Now we label this domain (policy name is optional, see above): 110.123 - 110.124 - # xm addlabel homebanking.xm dom_HomeBanking example.chwall_ste.client_v1 110.125 - 110.126 -The domain configuration should look now like: 110.127 - 110.128 - # cat homebanking.xm 110.129 - #------FOR HOME/ONLINE BANKING--------- 110.130 - kernel = "/boot/vmlinuz-2.6.16-xen" 110.131 - ramdisk="/boot/U1_ramdisk.img" 110.132 - memory = 164 110.133 - name = "homebanking" 110.134 - vif=[''] 110.135 - dhcp = "dhcp" 110.136 - access_control = ['policy=example.chwall_ste.client_v1, label=dom_HomeBanking'] 110.137 - 110.138 -You can see the access_control line that was added to the 110.139 -configuration. This label will be translated into a local ssidref when 110.140 -a domain is created or resumed (also after migration and 110.141 -live-migration). The ssidref is a local security reference that is 110.142 -used inside the hypervisor instead of the security label for 110.143 -efficiency reasons. Since the same label can be mapped onto different 110.144 -ssidrefs in different policy translations (e.g., if the position of 110.145 -the label definition is changed in the policy file) or on different 110.146 -systems, the ssidref is re-calculated from the label each time a 110.147 -domain is instantiated or re-instantiated. 110.148 - 110.149 -Currently, the labels are not held in the hypervisor but only in 110.150 -.map files in the /etc/xen/acm-security/policies subdirectories. Only 110.151 -ssidrefs are known inside the hypervisr. This of course can change in 110.152 -the future. 110.153 - 110.154 - 110.155 -4. Starting a labeled domain 110.156 -============================ 110.157 - 110.158 -Now, start the domain: 110.159 - 110.160 - #xm create homebanking.xm 110.161 - Using config file "homebanking.xm". 110.162 - Started domain fun 110.163 - 110.164 - 110.165 -[root@941e-4 VMconfigs]# xm list --label 110.166 - 110.167 -Name ID Mem(MiB) VCPUs State Time(s) Label 110.168 -fun 1 64 1 -b---- 5.9 dom_HomeBanking 110.169 -Domain-0 0 1954 1 r----- 1321.4 dom_SystemManagement 110.170 - 110.171 - 110.172 - 110.173 -If you label another domain configuration as dom_Fun and if 110.174 -you try to start it afterwards, this create will fail. 110.175 - 110.176 -Why? -- Because the running 'homebanking' domain has the chinese 110.177 -wall type "cw_Sensitive". The new domain 'fun' has the chinese wall 110.178 -label "cw_Distrusted". These domains are not allowed to run simultaneously 110.179 -on the same system because of the defined conflict set 110.180 - 110.181 - <conflictset name="Protection1"> 110.182 - <type>cw_Sensitive</type> 110.183 - <type>cw_Distrusted</type> 110.184 - </conflictset> 110.185 - 110.186 -(in client_v1-security_policy.xml), which says that only one of the 110.187 -types cw_Sensitive and cw_Distrusted can run at a time. 110.188 - 110.189 -If you save or shutdown the 'homebanking' domain, you will be able to 110.190 -start the 'fun' domain. You can look into the Xen log to see if a 110.191 -domain was denied to start because of the access control framework 110.192 -with the command 'xm dmesg'. 110.193 - 110.194 -It is important (and usually non-trivial) to define the labels in a 110.195 -way that the semantics of the labels are enforced and supported by the 110.196 -types and the conflict sets. Usually, a workload abstraction seems 110.197 -helpful on the hypervisor level. 110.198 - 110.199 -Note: While the chinese wall policy enforcement is complete, the type 110.200 -enforcement is currently enforced inside the Xen hypervisor 110.201 -only. Therefore, only point-to-point sharing with regard to the type 110.202 -enforcement is currently controlled. Enforcing the STE policy while 110.203 -sharing virtual resources is ongoing work and assumed to be complete 110.204 -by year end as well as enforcing the STE policy for network traffic 110.205 -routed through dom0. 110.206 - 110.207 - 110.208 -5. Adding your own policies 110.209 -=========================== 110.210 - 110.211 -Writing your own policy (e.g. "mypolicy.chwall.test") requires the policy 110.212 -definition (types etc.) and the label definitions. Any policy name 110.213 -must have chwall, ste, or chwall_ste in its name. This is used by the 110.214 -configuration tool to identify existing binary policy entries in the 110.215 -boot configuration file (menu.lst, grub.con). This part should, of 110.216 -course, be consistent with policy type that is defined. 110.217 - 110.218 -First, you create 110.219 -/etc/xen/acm-security/policies/mypolicy/chwall/test-security_policy.xml. 110.220 - 110.221 -You need to keep to the schema as defined in 110.222 -/etc/xen/acm-security/security_policy.xsd since the translation tools 110.223 -are written against this schema. 110.224 - 110.225 -You can hand-edit the xml files to create your policy or you can use the 110.226 -xensec_gen utility. 110.227 - 110.228 - 110.229 -6. Generating policy files using xensec_gen: 110.230 -============================================ 110.231 - 110.232 -The xensec_gen utility starts a web-server that can be used to generate the 110.233 -XML policy files needed to create a policy. 110.234 - 110.235 -By default, xensec_gen runs as a daemon and listens on port 7777 for HTTP 110.236 -requests. The xensec_gen command supports command line options to change the 110.237 -listen port, run in the foreground, and a few others. Type 'xensec_gen -h' 110.238 -to see the full list of options available. 110.239 - 110.240 -Once the xensec_gen utility is running, point a browser at the host and port 110.241 -on which the utility is running (e.g. http://localhost:7777/). You will be 110.242 -presented with a web page that allows you to create or modify the XML policy 110.243 -file: 110.244 - 110.245 - - The Security Policy types section allows you to create or modify 110.246 - the policy types and conflict set definitions 110.247 - 110.248 - - The Security Policy Labeling section allows you to create or modify a 110.249 - label definitions 110.250 - 110.251 -The policy generation tool allows you to modify an existing policy 110.252 -definition or create a new policy definition file. To modify an 110.253 -existing policy definition, enter the full path to the existing file 110.254 -(the "Browse" button can be used to aid in this) in the Policy File 110.255 -entry field. To create a new policy definition file leave the Policy 110.256 -File entry field blank. At this point click the "Create" button to 110.257 -begin modifying or creating your policy definition. 110.258 - 110.259 - Security Policy Types Section 110.260 - ----------------------------- 110.261 - 110.262 -You will then be presented with a web page. The upper part of it will 110.263 -allow you to create either Simple Type Enforcement types or Chinese 110.264 -Wall types or both, as well as Chinese Wall conflict type sets. 110.265 - 110.266 - As an example: 110.267 - - To add a Simple Type Enforcement type: 110.268 - - Enter the name of a new type under the Simple Type Enforcement Types 110.269 - section in the entry field above the "New" button. 110.270 - - Click the "New" button and the type will be added to the list of defined 110.271 - Simple Type Enforcement types. 110.272 - - To remove a Simple Type Enforcement type: 110.273 - - Click on the type to be removed in the list of defined Simple Type 110.274 - Enforcement types. 110.275 - - Click the "Delete" button to remove the type. 110.276 - 110.277 - Follow the same process to add Chinese Wall types. If you define Chinese Wall 110.278 - types you need to define at least one Chinese Wall Conflict Set. The Chinese 110.279 - Wall Conflict Set will allow you to add Chinese Wall types from the list of 110.280 - defined Chinese Wall types. 110.281 - 110.282 - Security Policy Labeling: 110.283 - ------------------------- 110.284 - 110.285 - The security policy label section of the web page allows you to create labels 110.286 - for classes of virtual machines. The input policy type definitions on the upper 110.287 - part of the web page will provide the available types (Simple Type Enforcement 110.288 - and/or Chinese Wall) that can be assigned to a virtual machine class. 110.289 - 110.290 - As an example: 110.291 - - To add a Virtual Machine class (the name entered will become the label 110.292 - that will be used to identify the class): 110.293 - - Enter the name of a new class under the Virtual Machine Classes section 110.294 - in the entry field above the "New" button. 110.295 - - Click the "New" button and the class will be added to the table of defined 110.296 - Virtual Machine classes. 110.297 - - To remove a Virtual Machine class: 110.298 - - Click the "Delete" link associated with the class in the table of Virtual 110.299 - Machine classes. 110.300 - 110.301 - Once you have defined one or more Virtual Machine classes, you will be able to 110.302 - add any of the defined Simple Type Enforcement types or Chinese Wall types to a 110.303 - particular Virtual Machine. 110.304 - 110.305 - You must also define which Virtual Machine class is to be associated with the 110.306 - bootstrap domain (or Dom0 domain). By default, the first Virtual Machine class 110.307 - created will be associated as the bootstrap domain. 110.308 - 110.309 - To save your policy definition file, click on the "Generate XML" button 110.310 - on the top of the page. This will present you with a dialog box to save the 110.311 - generated XML file on your system. The default name will be 110.312 - security_policy.xml which you should change to follow the policy file 110.313 - naming conventions based on the policy name that you choose to use. 110.314 - 110.315 - To get a feel for the tool, you could use one of the example policy definitions 110.316 - files from /etc/xen/acm-security/policies/example as input. 110.317 - 110.318 - 110.319 -7. Hypervisor - OS Security Interface 110.320 -===================================== 110.321 - 110.322 -We currently provide 2 hypercalls through which user operating systems 110.323 -can interact with the hypervisor Access Control Module. Examples of 110.324 -using them are under "xen_root"/tools/security/python/xensec_tools: 110.325 - 110.326 - 110.327 -I) acm_getdecision -i domainid -l labelname 110.328 - Call this example script without arguments to show its usage 110.329 - information. 110.330 - 110.331 - This script enables a domain to retrieve an access control decision 110.332 - regarding the STE policy from the hypervisor. It will be used to 110.333 - control access to virtual/real resources in hosting domains. 110.334 - 110.335 - The script can be provided with any combination of domain ids or 110.336 - labelnames. Before calling into the hypervisor, labels are translated 110.337 - into ssidrefs. The hypervisor then retrieves for any domain id 110.338 - paramter the ssidref before deciding access. 110.339 - 110.340 - Example: 110.341 - #/etc/xen/acm-security/scripts/acm_getdecision -l dom_Fun 110.342 - -l dom_SystemManagement 110.343 - PERMITTED 110.344 - 110.345 - #/etc/xen/acm-security/scripts/acm_getdecision -i 0 -i 1 110.346 - PERMITTED 110.347 - 110.348 - #/etc/xen/acm-security/scripts/acm_getdecision -i 0 -l dom_Fun 110.349 - PERMITTED 110.350 - 110.351 - #/etc/xen/acm-security/scripts/acm_getdecision -i 0 -l no_label 110.352 - ACMError: Label 'nolabel' not found. 110.353 - 110.354 - Now, assume domain 123454 does not exist: 110.355 - #/etc/xen/acm-security/scripts/acm_getdecision -i 123454 -l dom_Fun 110.356 - ACMError: Cannot determine decision (Invalid parameter). 110.357 - 110.358 - Return values: 110.359 - * DENIED: access is denied based on the current hypervisor 110.360 - policy 110.361 - 110.362 - * PERMITTED: access is permitted based on the current 110.363 - 110.364 - * Exception ACMError: one of the parameters was illegal, 110.365 - i.e. an unknown label or a 110.366 - non-existing domain id 110.367 - 110.368 -I) acm_getlabel -i domainid 110.369 - Retrieves the label of a runing domain. This function can be used 110.370 - by domains to determine their own label or (if authorized) the label 110.371 - other domains. 110.372 - 110.373 - Example (result is broken up into different lines to simplify description): 110.374 - # /etc/xen/acm-security/scripts/acm_getlabel -i 0 110.375 - ('example.chwall.client_v1', <--- policy describing labels etc. 110.376 - 'dom_SystemManagement', <--- label name of the domain 110.377 - 'CHINESE WALL', <--- policy type 110.378 - 65537) <--- hypervisor internal ssidref 110.379 -
111.1 --- a/tools/security/install.txt Sun Oct 22 14:39:15 2006 -0600 111.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 111.3 @@ -1,87 +0,0 @@ 111.4 -## 111.5 -# install.txt <description to the xen access control architecture> 111.6 -# 111.7 -# Author: 111.8 -# Reiner Sailer 08/15/2005 <sailer@watson.ibm.com> 111.9 -# 03/18/2006 update: new labeling 111.10 -# 111.11 -# 111.12 -# This file shows how to activate and install the access control 111.13 -# framework for Xen. 111.14 -## 111.15 - 111.16 - 111.17 -INSTALLING A SECURITY POLICY IN XEN 111.18 -=================================== 111.19 - 111.20 -By default, the access control architecture is disabled in Xen. To 111.21 -enable the access control architecture in Xen follow the steps below. 111.22 -This description assumes that you want to install the Chinese Wall and 111.23 -Simple Type Enforcement policy. Some file names need to be replaced 111.24 -below to activate the Chinese Wall OR the Type Enforcement policy 111.25 -exclusively (chwall_ste --> {chwall, ste}). 111.26 - 111.27 -0. build and install the xm man page. It includes the description of 111.28 - available management commands for the security policy for Xen and 111.29 - the labeling of domains. If not installed by default, you can make 111.30 - and install the xm man page as follows: 111.31 - # cd "xen_root"/doc 111.32 - # make install 111.33 - Then, use man xm to read it: 111.34 - # man xm 111.35 - 111.36 -1. enable access control in Xen 111.37 - # cd "xen_root" 111.38 - # edit/xemacs/vi Config.mk 111.39 - 111.40 - change the lines: 111.41 - ACM_SECURITY ?= n 111.42 - to: 111.43 - ACM_SECURITY ?= y 111.44 - 111.45 - Now the hypervisor will boot into the policy that is specified 111.46 - in the grub configuration. If you would like to boot into a 111.47 - specific policy (even if you can't specify a boot policy but 111.48 - need to set the policy later using the 'xensec_tool 111.49 - loadpolicy'), then use the other config parameter to change 111.50 - from NULL to any other default policy, e.g.: 111.51 - ACM_DEFAULT_SECURITY_POLICY ?= ACM_CHINESE_WALL_AND_SIMPLE_TYPE_ENFORCEMENT_POLICY 111.52 - 111.53 - # make dist 111.54 - # ./install.sh 111.55 - 111.56 -2. Build acm and policy tools and create boot-able policy: 111.57 - # cd tools/security 111.58 - # make install 111.59 - 111.60 - For description of the following commands, please see the xm 111.61 - man page (docs/man1/xm.1). If it is not built, then you can 111.62 - create it manually: cd "xen_root"/docs; make; man man1/xm.1 111.63 - 111.64 - Step1: Building binary version of an example policy: 111.65 - # xm makepolicy example.chwall_ste.client_v1 111.66 - # xm cfgbootpolicy example.chwall_ste.client_v1 111.67 - 111.68 - Please verify boot entry in /boot/grub/grub.conf (or menu.lst): 111.69 - title Xen (2.6.16) 111.70 - root (hd0,0) 111.71 - kernel /xen.gz dom0_mem=2000000 console=vga 111.72 - module /vmlinuz-2.6.16-xen ro root=/dev/VolGroup00/LogVol00 rhgb 111.73 - module /initrd-2.6.165-xen-U.img 111.74 - module /example.chwall_ste.client_v1.bin 111.75 - 111.76 -3. reboot into the newly compiled hypervisor 111.77 - 111.78 - after boot 111.79 - # xm dmesg should show an entry about the policy being loaded 111.80 - during the boot process 111.81 - 111.82 - # xm dumppolicy 111.83 - should print the new binary policy representation 111.84 - including the policy name example.chwall_ste.client_v1 111.85 - 111.86 - # xm list --label 111.87 - should show security label names behind the running domains 111.88 - 111.89 -For more information about how to use the security-enabled Xen, see 111.90 -the examples.txt file in this directory.
112.1 --- a/tools/security/policy.txt Sun Oct 22 14:39:15 2006 -0600 112.2 +++ b/tools/security/policy.txt Sun Oct 22 15:23:52 2006 -0600 112.3 @@ -1,131 +1,13 @@ 112.4 ## 112.5 -# policy.txt <description to the Xen access control architecture> 112.6 +# policy.txt <description to the sHype/Xen access control architecture> 112.7 # 112.8 # Author: 112.9 -# Reiner Sailer 08/15/2005 <sailer@watson.ibm.com> 112.10 +# Reiner Sailer 08/30/2006 <sailer@watson.ibm.com> 112.11 # 112.12 # 112.13 -# This file gives an overview of the security policies currently 112.14 -# provided and also gives some reasoning about how to assign 112.15 -# labels to domains. 112.16 +# This file gives an overview of the example security policies. 112.17 ## 112.18 112.19 -Xen access control policies 112.20 - 112.21 - 112.22 -General explanation of supported security policies: 112.23 -===================================================== 112.24 - 112.25 -We have implemented the mandatory access control architecture of our 112.26 -hypervisor security architecture (sHype) for the Xen hypervisor. It 112.27 -controls communication (in Xen: event channels, grant tables) between 112.28 -Virtual Machines (from here on called domains) and through this the 112.29 -virtual block devices, networking, and shared memory are implemented 112.30 -on top of these communication means. While we have implemented the 112.31 -described policies and access control architecture for other 112.32 -hypervisor systems, we will describe below specifically its 112.33 -implementation and use in the Xen hypervisor. The policy enforcement 112.34 -is called mandatory regarding user domains since the policy it is 112.35 -given by the security administration and enforced independently of the 112.36 -user domains by the Xen hypervisor in cooperation with the domain 112.37 -management. 112.38 - 112.39 -The access control architecture consists of three parts: 112.40 - 112.41 -i) The access control policy determines the "command set" of the ACM 112.42 -and the hooks with which they can be configured to constrain the 112.43 -sharing of virtual resources. The current access control architecture 112.44 -implemented for Xen supports two policies: Chinese Wall and Simple 112.45 -Type Enforcement, which we describe in turn below. 112.46 - 112.47 - 112.48 -ii) The actually enforced policy instantiation uses the policy 112.49 -language (i) to configure the Xen access control in a way that suits 112.50 -the specific application (home desktop environment, company desktop, 112.51 -Web server system, etc.). We have defined an exemplary policy 112.52 -instantiation for Chinese Wall (chwall policy) and Simple Type 112.53 -Enforcement (ste policy) for a desktop system. We offer these policies 112.54 -in combination since they are controlling orthogonal events. 112.55 - 112.56 - 112.57 -iii) The access control module (ACM) and related hooks are part of the 112.58 -core hypervisor and their controls cannot be bypassed by domains. The 112.59 -ACM and hooks are the active security components. We refer to 112.60 -publications that describe how access control is enforced in the Xen 112.61 -hypervisor using the ACM (access decision) and the hooks (decision 112.62 -enforcement) inserted into the setup of event channels and grant 112.63 -tables, and into domain operations (create, destroy, save, restore, 112.64 -migrate). These controls decide based on the active policy 112.65 -configuration (see i. and ii.) if the operation proceeds of if the 112.66 -operation is aborted (denied). 112.67 - 112.68 -In general, security policy instantiations in the Xen access control 112.69 -framework are defined by XML policy files. Each security policy has 112.70 -exactly one file including all the information the hypervisor needs to 112.71 -enforce the policy. 112.72 - 112.73 -The name of a policy is unique and consists of a colon-separated list 112.74 -of names, which can be translated into the location (subtree) where 112.75 -this policy must be located. The last part of the name is the file 112.76 -name pre-fix for the policy xml file. The preceding name parts are 112.77 -translated into the local path relative to the global policy root 112.78 -(/etc/xen/acm-security/policies) pointing to the policy xml file. For 112.79 -example: example.chwall_ste.client_v1 denotes the policy file 112.80 -example/chwall_ste/client_v1-security_policy.xml relative to the 112.81 -global policy root directory. 112.82 - 112.83 -Every security policy has its own sub-directory under the global 112.84 -policy root directory /etc/xen/acm-security/policies, which is 112.85 -installed during the Xen installation or can be manually installed 112.86 -(when switching from a "security disabled" Xen to a "security enabled" 112.87 -Xen AFTER configuring security, see install.txt) by the command 112.88 -sequence: 112.89 - 112.90 - cd "Xen-root"/tools/security/policies; make install 112.91 - 112.92 -We will describe those files for our example policy (Chinese Wall and 112.93 -Simple Type Enforcement) in more detail as we go along. Eventually, we 112.94 -will move towards a system installation where the policies will reside 112.95 -under /etc. 112.96 - 112.97 - 112.98 -CHINESE WALL 112.99 -============ 112.100 - 112.101 -The Chinese Wall policy enables the user to define "which workloads 112.102 -(domain payloads) cannot run on a single physical system at the same 112.103 -time". Why would we want to prevent workloads from running at the same 112.104 -time on the same system? This supports requirements that can (but 112.105 -don't have to) be rooted in the measure of trust into the isolation of 112.106 -different domains that share the same hardware. Since the access 112.107 -control architecture aims at high performance and non-intrusive 112.108 -implementation, it currently does not address covert (timing) channels 112.109 -and aims at medium assurance. Users can apply the Chinese Wall policy 112.110 -to guarantee an air-gap between very sensitive payloads both regarding 112.111 -covert information channels and regarding resource starvation. 112.112 - 112.113 -To enable the CW control, each domain is labeled with a set of Chinese 112.114 -Wall types and CW Conflict Sets are defined which include those CW 112.115 -types that cannot run simultaneously on the same hardware. This 112.116 -interpretation of conflict sets is the only policy rule for the Chines 112.117 -Wall policy. 112.118 - 112.119 -This is enforced by controlling the start of domains according to 112.120 -their assigned CW worload types. Domains with Chinese Wall types that 112.121 -appear in a common conflict set are running mutually exclusive on a 112.122 -platform, i.e., once a domain with one of the cw-types of a conflict 112.123 -set is running, no domain with another cw-type of the same conflict 112.124 -set can start until the first domain is destroyed, paused, or migrated 112.125 -away from the physical system (this assumes that such a partition can 112.126 -no longer be observed). The idea is to assign cw-types according to 112.127 -the type of payload that a domain runs and to use the Chinese Wall 112.128 -policy to ensure that payload types can be differentiated by the 112.129 -hypervisor and can be prevented from being executed on the same system 112.130 -at the same time. Using the flexible CW policy maintains system 112.131 -consolidation and workload-balancing while introducing guaranteed 112.132 -constraints where necessary. 112.133 - 112.134 - 112.135 Example of a Chinese Wall Policy Instantiation 112.136 ---------------------------------------------- 112.137 112.138 @@ -233,13 +115,12 @@ Currently in Xen, Dom0 controls all hard 112.139 with all domains during their setup, and intercepts all communication 112.140 between domains. Consequently, Dom0 needs to be assigned all types 112.141 used and must be completely trusted to maintain the separation of 112.142 -informatio ncoming from domains with different STE types. Thus a 112.143 +information coming from domains with different STE types. Thus a 112.144 refactoring of Dom0 is recommended for stronger confinement 112.145 guarantees. 112.146 112.147 Domain --> RESOURCES Access 112.148 ''''''''''''''''''''''''''' 112.149 -(current work) 112.150 112.151 We define for each resource that we want to distinguish a separate STE 112.152 type. Each STE type is assigned to the respective resource and to 112.153 @@ -266,8 +147,7 @@ maximum security benefit from sHype. 112.154 112.155 Example of a Simple Type Enforcement Policy Instantiation 112.156 --------------------------------------------------------- 112.157 - 112.158 -We define the following types: 112.159 +The example policies define the following types: 112.160 112.161 * ste_SystemManagement identifies workloads (and domains that runs 112.162 them) that must share information to accomplish the management of the 112.163 @@ -384,19 +264,18 @@ Xen components and these components use 112.164 co-operatively enforce the policy. In the storage domain example, we 112.165 have three components that co-operate: 112.166 112.167 -1. The ACM module inside the hypervisor enforces: communication between 112.168 -user domains and the storage domain (only domains including types 112.169 -ste_PersonalFinances or ste_InternetInsecure can communicate with the 112.170 -storage domain and request access to logical resource). This confines 112.171 -the sharing to the types assigned to the storage domain. 112.172 +1. The ACM module inside the hypervisor enforces: communication 112.173 +between user domains and the storage domain (only domains including 112.174 +types ste_PersonalFinances or ste_InternetInsecure can communicate 112.175 +with the storage domain and request access to logical resource). This 112.176 +confines the sharing to the types assigned to the storage domain. 112.177 112.178 -2. The domain management will enforce (work in progress): assignment of 112.179 -real resources (hda) to domains (storage domain) that share a 112.180 -type with the resource. 112.181 +2. The domain management enforces: assignment of real resources (hda) 112.182 +to domains (storage domain) that share a type with the resource. 112.183 112.184 -3. If the storage domain serves multiple STE types (as in our example), 112.185 -it enforces (work in progress): that domains can access (mount) 112.186 -logical resources only if they share an STE type with the respective 112.187 +3. If the storage domain serves multiple STE types (as in our 112.188 +example), it enforces: that domains can access (mount) logical 112.189 +resources only if they share an STE type with the respective 112.190 resource. In our example, domains with the STE type 112.191 ste_PersonalFinances can request access (mount) to logical resource 112.192 hda1 from the storage domain. 112.193 @@ -406,8 +285,8 @@ see the minimal set of types assigned to 112.194 drive hda for serving logical disk partitions exclusively to 112.195 dom_HomeBanking and dom_Fun. 112.196 112.197 -Similary, network domains can confine access to the network or 112.198 -network communication between user domains. 112.199 +Similary, network domains can confine access to the network or network 112.200 +communication between user domains. 112.201 112.202 As a result, device domains (e.g., storage domain, network domain) 112.203 must be simple and small to ensure their correct co-operation in the
113.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 113.2 +++ b/tools/security/policytools.txt Sun Oct 22 15:23:52 2006 -0600 113.3 @@ -0,0 +1,148 @@ 113.4 +## 113.5 +# policytools.txt 113.6 +# <description to the sHype/Xen policy management tools> 113.7 +# 113.8 +# Author: 113.9 +# Reiner Sailer 08/31/2006 <sailer@watson.ibm.com> 113.10 +# 113.11 +# 113.12 +## 113.13 + 113.14 +This file describes the Xen-tools to create and maintain security 113.15 +policies for the sHype/Xen access control module. 113.16 + 113.17 +A security policy (e.g. "example.chwall_ste.test") is defined in 113.18 +XML. Read in the user manual about the naming of policies. The policy 113.19 +name is used by the Xen management tools to identify existing 113.20 +policies. Creating the security policy means creating a policy 113.21 +description in XML: 113.22 +/etc/xen/acm-security/policies/example/chwall_ste/test-security_policy.xml. 113.23 + 113.24 +The policy XML description must follow the XML schema definition in 113.25 +/etc/xen/acm-security/policies/security_policy.xsd. The policy tools 113.26 +are written against this schema; they will create and refine policies 113.27 +that conform to this scheme. 113.28 + 113.29 +Two tools are provided to help creating security policies: 113.30 + 113.31 + 113.32 +1. xensec_ezpolicy: The starting point for writing security policies. 113.33 +=================== 113.34 + 113.35 +This wxPython-based GUI tool is meant to create very quickly a 113.36 +starting point for a workload protection security policy. Please start 113.37 +the tool (xensec_ezpolicy) and press <CTRL-h> for usage explanations. 113.38 +The Xen User guide explains its usage at an example in chapter 113.39 +"sHype/Xen Access Control". 113.40 + 113.41 +The output of the tool is a security policy that is fully operable. It 113.42 +is sufficient to create policies that demonstrate how sHype/ACM works. 113.43 + 113.44 +However, it defines only a basic set of security labels assuming that 113.45 +Domain0 hosts and virtualizes all hardware (storage etc.). Use 113.46 +xensec_gen to refine this policy and tailor it to your requirements. 113.47 + 113.48 + 113.49 +2. xensec_gen: The tool to refine a basic security policy: 113.50 +============== 113.51 + 113.52 +The xensec_gen utility starts a web-server that can be used to 113.53 +generate the XML policy files needed to create or maintain a 113.54 +policy. It can be pre-loaded with a policy file created by 113.55 +xensec_ezpolicy. 113.56 + 113.57 +By default, xensec_gen runs as a daemon and listens on port 7777 for 113.58 +HTTP requests. The xensec_gen command supports command line options 113.59 +to change the listen port, run in the foreground, and a few others. 113.60 +Type 'xensec_gen -h' to see the full list of options available. 113.61 + 113.62 +Once the xensec_gen utility is running, point a browser at the host 113.63 +and port on which the utility is running (e.g. http://localhost:7777). 113.64 +You will be presented with a web page that allows you to create or 113.65 +modify the XML policy file: 113.66 + 113.67 + - The Security Policy types section allows you to create or modify 113.68 +the policy types and conflict set definitions 113.69 + 113.70 + - The Security Policy Labeling section allows you to create or 113.71 +modify label definitions 113.72 + 113.73 +The policy generation tool allows you to modify an existing policy 113.74 +definition or create a new policy definition file. To modify an 113.75 +existing policy definition, enter the full path to the existing file 113.76 +(the "Browse" button can be used to aid in this) in the Policy File 113.77 +entry field. To create a new policy definition file leave the Policy 113.78 +File entry field blank. At this point click the "Create" button to 113.79 +begin modifying or creating your policy definition. 113.80 + 113.81 + Security Policy Types Section 113.82 + ----------------------------- 113.83 + 113.84 +You will then be presented with a web page. The upper part of it will 113.85 +allow you to create either Simple Type Enforcement types or Chinese 113.86 +Wall types or both, as well as Chinese Wall conflict sets. 113.87 + 113.88 +As an example, to add a Simple Type Enforcement type: 113.89 + 113.90 +- Enter the name of a new type under the Simple Type Enforcement Types 113.91 +section in the entry field above the "New" button. 113.92 + 113.93 +- Click the "New" button and the type will be added to the list of 113.94 +defined Simple Type Enforcement types. 113.95 + 113.96 +To remove a Simple Type Enforcement type: 113.97 + 113.98 +- Click on the type to be removed in the list of defined Simple Type 113.99 +Enforcement types. 113.100 + 113.101 +- Click the "Delete" button to remove the type. 113.102 + 113.103 +Follow the same process to add Chinese Wall types. The Chinese Wall 113.104 +Conflict Set allows you to add Chinese Wall types from the list of 113.105 +defined Chinese Wall types. 113.106 + 113.107 + 113.108 + Security Policy Labels: 113.109 + ------------------------- 113.110 + 113.111 +The security policy label section of the web page allows you to create 113.112 +labels for classes of virtual machines and resources. The input 113.113 +policy type definitions on the upper part of the web page will provide 113.114 +the available types (Simple Type Enforcement and/or Chinese Wall) that 113.115 +can be assigned to a virtual machine class. Resource classes only 113.116 +include simple type enforcement types; the Chinese Wall policy does 113.117 +apply only to virtual machines. 113.118 + 113.119 +As an example, to add a Virtual Machine class (the name entered will 113.120 +become the label that will be used to identify the class): 113.121 + 113.122 +- Enter the name of a new class under the Virtual Machine Classes 113.123 +section in the entry field above the "New" button. 113.124 + 113.125 +- Click the "New" button and the class will be added to the table of 113.126 +defined Virtual Machine classes. 113.127 + 113.128 +To remove a Virtual Machine class: 113.129 + 113.130 +- Click the "Delete" link associated with the class in the table of 113.131 +Virtual Machine classes. 113.132 + 113.133 +Once you have defined one or more Virtual Machine classes, you will 113.134 +be able to add any of the defined Simple Type Enforcement types or 113.135 +Chinese Wall types to a particular Virtual Machine. 113.136 + 113.137 +If you create a new policy, you must also define which Virtual Machine 113.138 +class is to be associated with the bootstrap domain (or Dom0 domain). 113.139 +By default, the first Virtual Machine class created will be associated 113.140 +as the bootstrap domain. 113.141 + 113.142 +To save your policy definition file, click on the "Generate XML" 113.143 +button on the top of the page. This will present you with a dialog 113.144 +box to save the generated XML file on your system. The default name 113.145 +will be security_policy.xml which you should change to follow the 113.146 +policy file naming conventions based on the policy name that you 113.147 +choose to use. 113.148 + 113.149 +To get a feel for the tool, you could use one of the example policy 113.150 +definitions files from /etc/xen/acm-security/policies/example as 113.151 +input or a policy created by the xensec_ezpolicy tool.
114.1 --- a/tools/security/readme.txt Sun Oct 22 14:39:15 2006 -0600 114.2 +++ b/tools/security/readme.txt Sun Oct 22 15:23:52 2006 -0600 114.3 @@ -1,34 +1,33 @@ 114.4 114.5 ## 114.6 -# readme.txt <description to the xen access control architecture> 114.7 +# readme.txt <description to the sHype/Xen access control architecture> 114.8 # 114.9 # Author: 114.10 -# Reiner Sailer 08/15/2005 <sailer@watson.ibm.com> 114.11 +# Reiner Sailer 08/30/2006 <sailer@watson.ibm.com> 114.12 # 114.13 # 114.14 # This file is a toc for information regarding 114.15 # the access control policy and tools in Xen. 114.16 ## 114.17 114.18 -1. 'xm' man page 114.19 +1. Xen User Guide 114.20 + 114.21 + describes how to configure, install, and deploy the sHype Access 114.22 + Control Module in Xen. See chapter "sHype/Xen Access Control". 114.23 + 114.24 +2. 'xm' man page 114.25 114.26 describes the commands related to Xen management, including the 114.27 commands to manage security policies and labels. Read the access 114.28 - control subcommand section of the xm manual first. If it is not 114.29 - built by default, check install.txt. 114.30 + control subcommand section of the xm manual first. 114.31 114.32 -2. policy.txt: 114.33 +3. policy.txt 114.34 114.35 - describes the general reasoning and examples for access 114.36 - control policies in Xen 114.37 + describes examples for access control policies in Xen. First read 114.38 + the policy description in the Xen User Guide. 114.39 114.40 114.41 -3. install.txt 114.42 - 114.43 - describes the activation of the access control framework 114.44 - in Xen 114.45 +4. policytools.txt 114.46 114.47 -4. example.txt 114.48 - 114.49 - describes the available tools for managing security policies 114.50 - in Xen and the tools to label domains 114.51 + describes the available tools for creating and managing security 114.52 + policies in Xen.
115.1 --- a/tools/security/secpol_tool.c Sun Oct 22 14:39:15 2006 -0600 115.2 +++ b/tools/security/secpol_tool.c Sun Oct 22 15:23:52 2006 -0600 115.3 @@ -43,6 +43,8 @@ 115.4 fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a , \ 115.5 errno, strerror(errno)) 115.6 115.7 +#define ALIGN8(x) (void *)(((long)(x) + 7) & ~7) 115.8 + 115.9 void usage(char *progname) 115.10 { 115.11 printf("Usage: %s ACTION\n" 115.12 @@ -182,14 +184,14 @@ void acm_dump_policy_buffer(void *buf, i 115.13 ntohl(pol->secondary_buffer_offset)); 115.14 switch (ntohl(pol->primary_policy_code)) { 115.15 case ACM_CHINESE_WALL_POLICY: 115.16 - acm_dump_chinesewall_buffer(buf + 115.17 - ntohl(pol->primary_buffer_offset), 115.18 + acm_dump_chinesewall_buffer(ALIGN8(buf + 115.19 + ntohl(pol->primary_buffer_offset)), 115.20 ntohl(pol->len) - 115.21 ntohl(pol->primary_buffer_offset)); 115.22 break; 115.23 115.24 case ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY: 115.25 - acm_dump_ste_buffer(buf + ntohl(pol->primary_buffer_offset), 115.26 + acm_dump_ste_buffer(ALIGN8(buf + ntohl(pol->primary_buffer_offset)), 115.27 ntohl(pol->len) - 115.28 ntohl(pol->primary_buffer_offset)); 115.29 break; 115.30 @@ -204,14 +206,14 @@ void acm_dump_policy_buffer(void *buf, i 115.31 115.32 switch (ntohl(pol->secondary_policy_code)) { 115.33 case ACM_CHINESE_WALL_POLICY: 115.34 - acm_dump_chinesewall_buffer(buf + 115.35 - ntohl(pol->secondary_buffer_offset), 115.36 + acm_dump_chinesewall_buffer(ALIGN8(buf + 115.37 + ntohl(pol->secondary_buffer_offset)), 115.38 ntohl(pol->len) - 115.39 ntohl(pol->secondary_buffer_offset)); 115.40 break; 115.41 115.42 case ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY: 115.43 - acm_dump_ste_buffer(buf + ntohl(pol->secondary_buffer_offset), 115.44 + acm_dump_ste_buffer(ALIGN8(buf + ntohl(pol->secondary_buffer_offset)), 115.45 ntohl(pol->len) - 115.46 ntohl(pol->secondary_buffer_offset)); 115.47 break;
116.1 --- a/tools/security/secpol_xml2bin.c Sun Oct 22 14:39:15 2006 -0600 116.2 +++ b/tools/security/secpol_xml2bin.c Sun Oct 22 15:23:52 2006 -0600 116.3 @@ -979,13 +979,15 @@ unsigned char *write_policy_reference_bi 116.4 unsigned char *buf, *ptr; 116.5 struct acm_policy_reference_buffer *pr_header; 116.6 u_int32_t len; 116.7 + u_int32_t name_len; 116.8 116.9 if (policy_reference_name == NULL) { 116.10 printf("ERROR: No policy reference name found.\n"); 116.11 exit(EXIT_FAILURE); 116.12 } 116.13 - len = (sizeof(struct acm_policy_reference_buffer) + 116.14 - strlen(policy_reference_name) + 1); 116.15 + name_len = strlen(policy_reference_name) + 1; /* strend '\0' */ 116.16 + len = sizeof(struct acm_policy_reference_buffer) + name_len; 116.17 + len = (len + 7) & ~7; /* Alignment. */ 116.18 buf = malloc(len); 116.19 ptr = buf; 116.20 116.21 @@ -994,9 +996,9 @@ unsigned char *write_policy_reference_bi 116.22 ("ERROR: out of memory allocating label reference buffer.\n"); 116.23 exit(EXIT_FAILURE); 116.24 } 116.25 + memset (buf, 0, len); 116.26 pr_header = (struct acm_policy_reference_buffer *) buf; 116.27 - pr_header->len = 116.28 - htonl(strlen(policy_reference_name) + 1 /* strend \'0' */ ); 116.29 + pr_header->len = htonl(name_len); 116.30 ptr += sizeof(struct acm_policy_reference_buffer); 116.31 strcpy((char *) ptr, policy_reference_name); 116.32
117.1 --- a/tools/vnet/doc/Makefile Sun Oct 22 14:39:15 2006 -0600 117.2 +++ b/tools/vnet/doc/Makefile Sun Oct 22 15:23:52 2006 -0600 117.3 @@ -1,12 +1,11 @@ 117.4 #!/usr/bin/make -f 117.5 # -*- mode: Makefile; -*- 117.6 +XEN_ROOT = ../../.. 117.7 +include $(XEN_ROOT)/tools/Rules.mk 117.8 117.9 VERSION = 1.0 117.10 HEADER = Vnet 117.11 117.12 -INSTALL = install 117.13 -INSTALL_DIR = $(INSTALL) -d -m0755 117.14 - 117.15 PS2PDF := ps2pdf 117.16 DVIPS := dvips 117.17 LATEX := latex
118.1 --- a/tools/vnet/examples/Makefile Sun Oct 22 14:39:15 2006 -0600 118.2 +++ b/tools/vnet/examples/Makefile Sun Oct 22 15:23:52 2006 -0600 118.3 @@ -1,9 +1,7 @@ 118.4 # -*- mode: Makefile; -*- 118.5 #============================================================================ 118.6 - 118.7 -INSTALL = install 118.8 -INSTALL_PROG = $(INSTALL) -m0755 118.9 -INSTALL_DIR = $(INSTALL) -d -m0755 118.10 +XEN_ROOT = ../../.. 118.11 +include $(XEN_ROOT)/tools/Rules.mk 118.12 118.13 XEN_SCRIPT_DIR = $(DESTDIR)/etc/xen/scripts 118.14
119.1 --- a/tools/vnet/libxutil/Makefile Sun Oct 22 14:39:15 2006 -0600 119.2 +++ b/tools/vnet/libxutil/Makefile Sun Oct 22 15:23:52 2006 -0600 119.3 @@ -3,11 +3,6 @@ export VNET_ROOT = $(shell cd .. && pwd) 119.4 include $(VNET_ROOT)/Make.env 119.5 endif 119.6 119.7 -INSTALL = install 119.8 -INSTALL_DATA = $(INSTALL) -m0644 119.9 -INSTALL_PROG = $(INSTALL) -m0755 119.10 -INSTALL_DIR = $(INSTALL) -d -m0755 119.11 - 119.12 include $(XEN_ROOT)/tools/Rules.mk 119.13 119.14 LIB_SRCS := 119.15 @@ -60,7 +55,7 @@ libxutil.so.$(MAJOR): libxutil.so.$(MAJO 119.16 ln -sf $^ $@ 119.17 119.18 libxutil.so.$(MAJOR).$(MINOR): $(PIC_OBJS) 119.19 - $(CC) $(CFLAGS) -Wl,-soname -Wl,libxutil.so.$(MAJOR) -shared -o $@ $^ 119.20 + $(CC) $(CFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxutil.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $^ 119.21 119.22 libxutil.a: $(LIB_OBJS) 119.23 $(AR) rc $@ $^
120.1 --- a/tools/vnet/scripts/Makefile Sun Oct 22 14:39:15 2006 -0600 120.2 +++ b/tools/vnet/scripts/Makefile Sun Oct 22 15:23:52 2006 -0600 120.3 @@ -1,9 +1,7 @@ 120.4 # -*- mode: Makefile; -*- 120.5 #============================================================================ 120.6 - 120.7 -INSTALL = install 120.8 -INSTALL_PROG = $(INSTALL) -m0755 120.9 -INSTALL_DIR = $(INSTALL) -d -m0755 120.10 +XEN_ROOT = ../../.. 120.11 +include $(XEN_ROOT)/tools/Rules.mk 120.12 120.13 SBIN_DIR = $(DESTDIR)/usr/sbin 120.14
121.1 --- a/tools/vnet/vnetd/Makefile Sun Oct 22 14:39:15 2006 -0600 121.2 +++ b/tools/vnet/vnetd/Makefile Sun Oct 22 15:23:52 2006 -0600 121.3 @@ -110,7 +110,7 @@ vnetd: $(VNETD_OBJ) 121.4 .PHONY: install 121.5 install: vnetd 121.6 mkdir -p $(DESTDIR)$(VNETD_INSTALL_DIR) 121.7 - install -m 0755 vnetd $(DESTDIR)$(VNETD_INSTALL_DIR) 121.8 + $(INSTALL_PROG) vnetd $(DESTDIR)$(VNETD_INSTALL_DIR) 121.9 121.10 .PHONY: clean 121.11 clean:
122.1 --- a/tools/vtpm/Rules.mk Sun Oct 22 14:39:15 2006 -0600 122.2 +++ b/tools/vtpm/Rules.mk Sun Oct 22 15:23:52 2006 -0600 122.3 @@ -5,11 +5,6 @@ include $(XEN_ROOT)/tools/Rules.mk 122.4 # Tool definitions 122.5 # 122.6 122.7 -# Installation program and options 122.8 -INSTALL = install 122.9 -INSTALL_PROG = $(INSTALL) -m0755 122.10 -INSTALL_DIR = $(INSTALL) -d -m0755 122.11 - 122.12 # Xen tools installation directory 122.13 TOOLS_INSTALL_DIR = $(DESTDIR)/usr/bin 122.14
123.1 --- a/tools/vtpm_manager/Rules.mk Sun Oct 22 14:39:15 2006 -0600 123.2 +++ b/tools/vtpm_manager/Rules.mk Sun Oct 22 15:23:52 2006 -0600 123.3 @@ -5,11 +5,6 @@ include $(XEN_ROOT)/tools/Rules.mk 123.4 # Tool definitions 123.5 # 123.6 123.7 -# Installation program and options 123.8 -INSTALL = install 123.9 -INSTALL_PROG = $(INSTALL) -m0755 123.10 -INSTALL_DIR = $(INSTALL) -d -m0755 123.11 - 123.12 # Xen tools installation directory 123.13 TOOLS_INSTALL_DIR = $(DESTDIR)/usr/bin 123.14
124.1 --- a/tools/xcutils/Makefile Sun Oct 22 14:39:15 2006 -0600 124.2 +++ b/tools/xcutils/Makefile Sun Oct 22 15:23:52 2006 -0600 124.3 @@ -8,10 +8,6 @@ 124.4 # Copyright (C) 2005 by Christian Limpach 124.5 # 124.6 124.7 -INSTALL = install 124.8 -INSTALL_PROG = $(INSTALL) -m0755 124.9 -INSTALL_DIR = $(INSTALL) -d -m0755 124.10 - 124.11 XEN_ROOT = ../.. 124.12 include $(XEN_ROOT)/tools/Rules.mk 124.13 124.14 @@ -37,7 +33,7 @@ all: build 124.15 build: $(PROGRAMS) 124.16 124.17 $(PROGRAMS): %: %.o 124.18 - $(LINK.o) $^ $(LDLIBS) -o $@ 124.19 + $(CC) $(CFLAGS) $^ $(LDLIBS) -o $@ 124.20 124.21 .PHONY: install 124.22 install: build
125.1 --- a/tools/xcutils/readnotes.c Sun Oct 22 14:39:15 2006 -0600 125.2 +++ b/tools/xcutils/readnotes.c Sun Oct 22 15:23:52 2006 -0600 125.3 @@ -56,7 +56,8 @@ static void print_numeric_note(const cha 125.4 prefix, *(uint64_t *)ELFNOTE_DESC(note)); 125.5 break; 125.6 default: 125.7 - printf("%s: unknown data size %#x\n", prefix, note->n_descsz); 125.8 + printf("%s: unknown data size %#lx\n", prefix, 125.9 + (unsigned long)note->n_descsz); 125.10 break; 125.11 } 125.12 } 125.13 @@ -301,7 +302,8 @@ int main(int argc, char **argv) 125.14 print_string_note("FEATURES", note); 125.15 break; 125.16 default: 125.17 - printf("unknown note type %#x\n", note->n_type); 125.18 + printf("unknown note type %#lx\n", 125.19 + (unsigned long)note->n_type); 125.20 break; 125.21 } 125.22 }
126.1 --- a/tools/xenmon/Makefile Sun Oct 22 14:39:15 2006 -0600 126.2 +++ b/tools/xenmon/Makefile Sun Oct 22 15:23:52 2006 -0600 126.3 @@ -10,16 +10,11 @@ 126.4 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 126.5 # GNU General Public License for more details. 126.6 126.7 -INSTALL = install 126.8 -INSTALL_PROG = $(INSTALL) -m0755 126.9 -INSTALL_DIR = $(INSTALL) -d -m0755 126.10 -INSTALL_DATA = $(INSTALL) -m0644 126.11 +XEN_ROOT=../.. 126.12 +include $(XEN_ROOT)/tools/Rules.mk 126.13 126.14 sbindir=/usr/sbin 126.15 126.16 -XEN_ROOT=../.. 126.17 -include $(XEN_ROOT)/tools/Rules.mk 126.18 - 126.19 CFLAGS += -Werror -g 126.20 CFLAGS += -I $(XEN_XC) 126.21 CFLAGS += -I $(XEN_LIBXC)
127.1 --- a/tools/xenstat/libxenstat/Makefile Sun Oct 22 14:39:15 2006 -0600 127.2 +++ b/tools/xenstat/libxenstat/Makefile Sun Oct 22 15:23:52 2006 -0600 127.3 @@ -16,10 +16,6 @@ XEN_ROOT=../../.. 127.4 include $(XEN_ROOT)/tools/Rules.mk 127.5 LINUX_ROOT := $(XEN_ROOT)/linux-2.6-xen-sparse 127.6 127.7 -INSTALL = install 127.8 -INSTALL_PROG = $(INSTALL) -m0755 -D 127.9 -INSTALL_DATA = $(INSTALL) -m0644 -D 127.10 - 127.11 prefix=/usr 127.12 includedir=$(prefix)/include 127.13 libdir=$(prefix)/lib 127.14 @@ -34,7 +30,7 @@ LIB=src/libxenstat.a 127.15 SHLIB=src/libxenstat.so.$(MAJOR).$(MINOR) 127.16 SHLIB_LINKS=src/libxenstat.so.$(MAJOR) src/libxenstat.so 127.17 OBJECTS=src/xenstat.o 127.18 -SONAME_FLAGS=-Wl,-soname -Wl,libxenstat.so.$(MAJOR) 127.19 +SONAME_FLAGS=-Wl,$(SONAME_LDFLAG) -Wl,libxenstat.so.$(MAJOR) 127.20 127.21 WARN_FLAGS=-Wall -Werror 127.22 127.23 @@ -49,7 +45,7 @@ all: $(LIB) 127.24 $(RANLIB) $@ 127.25 127.26 $(SHLIB): $(OBJECTS) 127.27 - $(CC) $(CFLAGS) $(LDFLAGS) $(SONAME_FLAGS) -shared -o $@ $(OBJECTS) \ 127.28 + $(CC) $(CFLAGS) $(LDFLAGS) $(SONAME_FLAGS) $(SHLIB_CFLAGS) -o $@ $(OBJECTS) \ 127.29 -lxenstore -lxenctrl 127.30 127.31 src/xenstat.o: src/xenstat.c src/xenstat.h 127.32 @@ -101,7 +97,7 @@ PYTHON_FLAGS=-I/usr/include/python$(PYTH 127.33 swig -python $(SWIG_FLAGS) -outdir $(@D) -o $(PYSRC) $< 127.34 127.35 $(PYLIB): $(PYSRC) 127.36 - $(CC) $(CFLAGS) $(LDFLAGS) $(PYTHON_FLAGS) -shared -lxenstat -o $@ $< 127.37 + $(CC) $(CFLAGS) $(LDFLAGS) $(PYTHON_FLAGS) $(SHLIB_CFLAGS) -lxenstat -o $@ $< 127.38 127.39 python-bindings: $(PYLIB) $(PYMOD) 127.40 127.41 @@ -122,7 +118,7 @@ PERL_FLAGS=`perl -MConfig -e 'print "$$C 127.42 swig -perl $(SWIG_FLAGS) -outdir $(@D) -o $(PERLSRC) $< 127.43 127.44 $(PERLLIB): $(PERLSRC) 127.45 - $(CC) $(CFLAGS) $(LDFLAGS) $(PERL_FLAGS) -shared -lxenstat -o $@ $< 127.46 + $(CC) $(CFLAGS) $(LDFLAGS) $(PERL_FLAGS) $(SHLIB_CFLAGS) -lxenstat -o $@ $< 127.47 127.48 .PHONY: perl-bindings 127.49 perl-bindings: $(PERLLIB) $(PERLMOD)
128.1 --- a/tools/xenstat/xentop/Makefile Sun Oct 22 14:39:15 2006 -0600 128.2 +++ b/tools/xenstat/xentop/Makefile Sun Oct 22 15:23:52 2006 -0600 128.3 @@ -18,10 +18,6 @@ ifneq ($(XENSTAT_XENTOP),y) 128.4 all install xentop: 128.5 else 128.6 128.7 -INSTALL = install 128.8 -INSTALL_PROG = $(INSTALL) -m0755 -D 128.9 -INSTALL_DATA = $(INSTALL) -m0644 -D 128.10 - 128.11 prefix=/usr 128.12 mandir=$(prefix)/share/man 128.13 man1dir=$(mandir)/man1 128.14 @@ -29,7 +25,7 @@ sbindir=$(prefix)/sbin 128.15 128.16 CFLAGS += -DGCC_PRINTF -Wall -Werror -I$(XEN_LIBXENSTAT) 128.17 LDFLAGS += -L$(XEN_LIBXENSTAT) 128.18 -LDLIBS += -lxenstat -lncurses 128.19 +LDLIBS += -lxenstat $(CURSES_LIBS) $(SOCKET_LIBS) 128.20 128.21 .PHONY: all 128.22 all: xentop 128.23 @@ -37,6 +33,7 @@ all: xentop 128.24 .PHONY: install 128.25 install: xentop xentop.1 128.26 $(INSTALL_PROG) xentop $(DESTDIR)$(sbindir)/xentop 128.27 + $(INSTALL_DIR) $(DESTDIR)$(man1dir) 128.28 $(INSTALL_DATA) xentop.1 $(DESTDIR)$(man1dir)/xentop.1 128.29 128.30 endif
129.1 --- a/tools/xenstat/xentop/xentop.c Sun Oct 22 14:39:15 2006 -0600 129.2 +++ b/tools/xenstat/xentop/xentop.c Sun Oct 22 15:23:52 2006 -0600 129.3 @@ -23,6 +23,7 @@ 129.4 #include <errno.h> 129.5 #include <stdio.h> 129.6 #include <stdlib.h> 129.7 +#include <stdarg.h> 129.8 #include <string.h> 129.9 #include <sys/time.h> 129.10 #include <time.h> 129.11 @@ -186,6 +187,8 @@ char prompt_val[PROMPT_VAL_LEN]; 129.12 int prompt_val_len = 0; 129.13 void (*prompt_complete_func)(char *); 129.14 129.15 +static WINDOW *cwin; 129.16 + 129.17 /* 129.18 * Function definitions 129.19 */ 129.20 @@ -222,7 +225,7 @@ static void version(void) 129.21 /* Clean up any open resources */ 129.22 static void cleanup(void) 129.23 { 129.24 - if(!isendwin()) 129.25 + if(cwin != NULL && !isendwin()) 129.26 endwin(); 129.27 if(prev_node != NULL) 129.28 xenstat_free_node(prev_node); 129.29 @@ -235,7 +238,7 @@ static void cleanup(void) 129.30 /* Display the given message and gracefully exit */ 129.31 static void fail(const char *str) 129.32 { 129.33 - if(!isendwin()) 129.34 + if(cwin != NULL && !isendwin()) 129.35 endwin(); 129.36 fprintf(stderr, str); 129.37 exit(1); 129.38 @@ -266,7 +269,7 @@ static void print(const char *fmt, ...) 129.39 if (!batch) { 129.40 if((current_row() < lines()-1)) { 129.41 va_start(args, fmt); 129.42 - vw_printw(stdscr, fmt, args); 129.43 + vwprintw(stdscr, (char *)fmt, args); 129.44 va_end(args); 129.45 } 129.46 } else { 129.47 @@ -280,7 +283,7 @@ static void print(const char *fmt, ...) 129.48 static void attr_addstr(int attr, const char *str) 129.49 { 129.50 attron(attr); 129.51 - addstr(str); 129.52 + addstr((char *)str); 129.53 attroff(attr); 129.54 } 129.55 129.56 @@ -1028,14 +1031,16 @@ int main(int argc, char **argv) 129.57 129.58 if (!batch) { 129.59 /* Begin curses stuff */ 129.60 - initscr(); 129.61 + cwin = initscr(); 129.62 start_color(); 129.63 cbreak(); 129.64 noecho(); 129.65 nonl(); 129.66 keypad(stdscr, TRUE); 129.67 halfdelay(5); 129.68 +#ifndef __sun__ 129.69 use_default_colors(); 129.70 +#endif 129.71 init_pair(1, -1, COLOR_YELLOW); 129.72 129.73 do {
130.1 --- a/tools/xenstore/Makefile Sun Oct 22 14:39:15 2006 -0600 130.2 +++ b/tools/xenstore/Makefile Sun Oct 22 15:23:52 2006 -0600 130.3 @@ -5,11 +5,6 @@ XEN_LIBXC = $(XEN_ROOT)/tools/l 130.4 MAJOR = 3.0 130.5 MINOR = 0 130.6 130.7 -INSTALL = install 130.8 -INSTALL_DATA = $(INSTALL) -m0644 130.9 -INSTALL_PROG = $(INSTALL) -m0755 130.10 -INSTALL_DIR = $(INSTALL) -d -m0755 130.11 - 130.12 PROFILE=#-pg 130.13 BASECFLAGS=-Wall -g -Werror 130.14 # Make gcc generate dependencies. 130.15 @@ -32,39 +27,40 @@ CLIENTS_OBJS := $(patsubst xenstore-%,xe 130.16 130.17 XENSTORED_OBJS = xenstored_core.o xenstored_watch.o xenstored_domain.o xenstored_transaction.o xs_lib.o talloc.o utils.o tdb.o hashtable.o 130.18 130.19 -XENSTORED_Linux = xenstored_linux.o 130.20 +XENSTORED_OBJS_$(CONFIG_Linux) = xenstored_linux.o 130.21 +XENSTORED_OBJS_$(CONFIG_SunOS) = xenstored_solaris.o 130.22 130.23 -XENSTORED_OBJS += $(XENSTORED_$(OS)) 130.24 +XENSTORED_OBJS += $(XENSTORED_OBJS_y) 130.25 130.26 .PHONY: all 130.27 all: libxenstore.so libxenstore.a xenstored $(CLIENTS) xs_tdb_dump xenstore-control xenstore-ls 130.28 130.29 test_interleaved_transactions: test_interleaved_transactions.o 130.30 - $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -L. -lxenstore -o $@ 130.31 + $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -L. -lxenstore -o $@ 130.32 130.33 .PHONY: testcode 130.34 testcode: xs_test xenstored_test xs_random 130.35 130.36 xenstored: $(XENSTORED_OBJS) 130.37 - $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -lxenctrl -o $@ 130.38 + $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -lxenctrl $(SOCKET_LIBS) -o $@ 130.39 130.40 $(CLIENTS): xenstore-%: xenstore_%.o libxenstore.so 130.41 - $(LINK.o) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore -o $@ 130.42 + $(CC) $(CFLAGS) $(LDFLAGS) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore $(SOCKET_LIBS) -o $@ 130.43 130.44 $(CLIENTS_OBJS): xenstore_%.o: xenstore_client.c 130.45 $(COMPILE.c) -DCLIENT_$(*F) -o $@ $< 130.46 130.47 xenstore-control: xenstore_control.o libxenstore.so 130.48 - $(LINK.o) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore -o $@ 130.49 + $(CC) $(CFLAGS) $(LDFLAGS) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore $(SOCKET_LIBS) -o $@ 130.50 130.51 xenstore-ls: xsls.o libxenstore.so 130.52 - $(LINK.o) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore -o $@ 130.53 + $(CC) $(CFLAGS) $(LDFLAGS) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore $(SOCKET_LIBS) -o $@ 130.54 130.55 xenstored_test: xenstored_core_test.o xenstored_watch_test.o xenstored_domain_test.o xenstored_transaction_test.o xs_lib.o talloc_test.o fake_libxc.o utils.o tdb.o 130.56 - $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ 130.57 + $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ 130.58 130.59 xs_tdb_dump: xs_tdb_dump.o utils.o tdb.o talloc.o 130.60 - $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ 130.61 + $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ 130.62 130.63 xs_test xs_random xs_stress xs_crashme: LDFLAGS+=-lpthread 130.64 xs_test: xs_test.o xs_lib.o utils.o 130.65 @@ -95,7 +91,7 @@ libxenstore.so.$(MAJOR): libxenstore.so. 130.66 ln -sf $< $@ 130.67 130.68 libxenstore.so.$(MAJOR).$(MINOR): xs.opic xs_lib.opic 130.69 - $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-soname -Wl,libxenstore.so.$(MAJOR) -shared -o $@ $^ -lpthread 130.70 + $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenstore.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $^ -lpthread 130.71 130.72 libxenstore.a: xs.o xs_lib.o 130.73 $(AR) rcs libxenstore.a $^
131.1 --- a/tools/xenstore/xenstored_core.c Sun Oct 22 14:39:15 2006 -0600 131.2 +++ b/tools/xenstore/xenstored_core.c Sun Oct 22 15:23:52 2006 -0600 131.3 @@ -1688,7 +1688,7 @@ static void write_pidfile(const char *pi 131.4 if (lockf(fd, F_TLOCK, 0) == -1) 131.5 exit(0); 131.6 131.7 - len = sprintf(buf, "%d\n", getpid()); 131.8 + len = sprintf(buf, "%ld\n", (long)getpid()); 131.9 if (write(fd, buf, len) != len) 131.10 barf_perror("Writing pid file %s", pidfile); 131.11 } 131.12 @@ -1901,7 +1901,7 @@ int main(int argc, char *argv[]) 131.13 restore_existing_connections(); 131.14 131.15 if (outputpid) { 131.16 - printf("%i\n", getpid()); 131.17 + printf("%ld\n", (long)getpid()); 131.18 fflush(stdout); 131.19 } 131.20 131.21 @@ -1924,6 +1924,9 @@ int main(int argc, char *argv[]) 131.22 /* Get ready to listen to the tools. */ 131.23 max = initialize_set(&inset, &outset, *sock, *ro_sock); 131.24 131.25 + /* Tell the kernel we're up and running. */ 131.26 + xenbus_notify_running(); 131.27 + 131.28 /* Main loop. */ 131.29 /* FIXME: Rewrite so noone can starve. */ 131.30 for (;;) {
132.1 --- a/tools/xenstore/xenstored_core.h Sun Oct 22 14:39:15 2006 -0600 132.2 +++ b/tools/xenstore/xenstored_core.h Sun Oct 22 15:23:52 2006 -0600 132.3 @@ -172,6 +172,9 @@ void *xenbus_map(void); 132.4 /* Return the event channel used by xenbus. */ 132.5 evtchn_port_t xenbus_evtchn(void); 132.6 132.7 +/* Tell the kernel xenstored is running. */ 132.8 +void xenbus_notify_running(void); 132.9 + 132.10 #endif /* _XENSTORED_CORE_H */ 132.11 132.12 /*
133.1 --- a/tools/xenstore/xenstored_linux.c Sun Oct 22 14:39:15 2006 -0600 133.2 +++ b/tools/xenstore/xenstored_linux.c Sun Oct 22 15:23:52 2006 -0600 133.3 @@ -67,3 +67,7 @@ void *xenbus_map(void) 133.4 133.5 return addr; 133.6 } 133.7 + 133.8 +void xenbus_notify_running(void) 133.9 +{ 133.10 +}
134.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 134.2 +++ b/tools/xenstore/xenstored_solaris.c Sun Oct 22 15:23:52 2006 -0600 134.3 @@ -0,0 +1,66 @@ 134.4 +/****************************************************************************** 134.5 + * 134.6 + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 134.7 + * Use is subject to license terms. 134.8 + * 134.9 + * Copyright (C) 2005 Rusty Russell IBM Corporation 134.10 + * 134.11 + * This program is free software; you can redistribute it and/or 134.12 + * modify it under the terms of the GNU General Public License as 134.13 + * published by the Free Software Foundation, version 2 of the 134.14 + * License. 134.15 + */ 134.16 + 134.17 +#include <fcntl.h> 134.18 +#include <unistd.h> 134.19 +#include <stdlib.h> 134.20 +#include <sys/mman.h> 134.21 +#include <xen/sys/xenbus.h> 134.22 + 134.23 +#include "xenstored_core.h" 134.24 + 134.25 +evtchn_port_t xenbus_evtchn(void) 134.26 +{ 134.27 + int fd; 134.28 + evtchn_port_t port; 134.29 + 134.30 + fd = open("/dev/xen/xenbus", O_RDONLY); 134.31 + if (fd == -1) 134.32 + return -1; 134.33 + 134.34 + port = ioctl(fd, IOCTL_XENBUS_XENSTORE_EVTCHN); 134.35 + 134.36 + close(fd); 134.37 + return port; 134.38 +} 134.39 + 134.40 +void *xenbus_map(void) 134.41 +{ 134.42 + int fd; 134.43 + void *addr; 134.44 + 134.45 + fd = open("/dev/xen/xenbus", O_RDWR); 134.46 + if (fd == -1) 134.47 + return NULL; 134.48 + 134.49 + addr = mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE, 134.50 + MAP_SHARED, fd, 0); 134.51 + 134.52 + if (addr == MAP_FAILED) 134.53 + addr = NULL; 134.54 + 134.55 + close(fd); 134.56 + 134.57 + return addr; 134.58 +} 134.59 + 134.60 +void xenbus_notify_running(void) 134.61 +{ 134.62 + int fd; 134.63 + 134.64 + fd = open("/dev/xen/xenbus", O_RDONLY); 134.65 + 134.66 + (void) ioctl(fd, IOCTL_XENBUS_NOTIFY_UP); 134.67 + 134.68 + close(fd); 134.69 +}
135.1 --- a/tools/xenstore/xs_lib.c Sun Oct 22 14:39:15 2006 -0600 135.2 +++ b/tools/xenstore/xs_lib.c Sun Oct 22 15:23:52 2006 -0600 135.3 @@ -76,7 +76,14 @@ const char *xs_daemon_socket_ro(void) 135.4 const char *xs_domain_dev(void) 135.5 { 135.6 char *s = getenv("XENSTORED_PATH"); 135.7 - return (s ? s : "/proc/xen/xenbus"); 135.8 + if (s) 135.9 + return s; 135.10 + 135.11 +#ifdef __linux__ 135.12 + return "/proc/xen/xenbus"; 135.13 +#else 135.14 + return "/dev/xen/xenbus"; 135.15 +#endif 135.16 } 135.17 135.18 /* Simple routines for writing to sockets, etc. */
136.1 --- a/tools/xenstore/xsls.c Sun Oct 22 14:39:15 2006 -0600 136.2 +++ b/tools/xenstore/xsls.c Sun Oct 22 15:23:52 2006 -0600 136.3 @@ -6,6 +6,7 @@ 136.4 #include <getopt.h> 136.5 #include <unistd.h> 136.6 #include <sys/ioctl.h> 136.7 +#include <termios.h> 136.8 136.9 static int max_width = 80; 136.10 static int desired_width = 60;
137.1 --- a/tools/xentrace/Makefile Sun Oct 22 14:39:15 2006 -0600 137.2 +++ b/tools/xentrace/Makefile Sun Oct 22 15:23:52 2006 -0600 137.3 @@ -1,8 +1,3 @@ 137.4 -INSTALL = install 137.5 -INSTALL_PROG = $(INSTALL) -m0755 137.6 -INSTALL_DIR = $(INSTALL) -d -m0755 137.7 -INSTALL_DATA = $(INSTALL) -m0644 137.8 - 137.9 XEN_ROOT=../.. 137.10 include $(XEN_ROOT)/tools/Rules.mk 137.11
138.1 --- a/tools/xentrace/formats Sun Oct 22 14:39:15 2006 -0600 138.2 +++ b/tools/xentrace/formats Sun Oct 22 15:23:52 2006 -0600 138.3 @@ -12,10 +12,29 @@ 0x0002f00B CPU%(cpu)d %(tsc)d s_timer_f 138.4 0x0002f00c CPU%(cpu)d %(tsc)d t_timer_fn 138.5 0x0002f00d CPU%(cpu)d %(tsc)d dom_timer_fn 138.6 138.7 -0x00080001 CPU%(cpu)d %(tsc)d VMX_VMEXIT [ domid = 0x%(1)08x, eip = 0x%(2)08x, reason = 0x%(3)08x ] 138.8 -0x00080002 CPU%(cpu)d %(tsc)d VMX_VECTOR [ domid = 0x%(1)08x, eip = 0x%(2)08x, vector = 0x%(3)08x ] 138.9 -0x00080003 CPU%(cpu)d %(tsc)d VMX_INT [ domid = 0x%(1)08x, trap = 0x%(2)08x, va = 0x%(3)08x ] 138.10 +0x00080001 CPU%(cpu)d %(tsc)d VMX_VMEXIT [ domid = 0x%(1)08x, eip = 0x%(2)08x, reason = 0x%(3)08x ] 138.11 +0x00084001 CPU%(cpu)d %(tsc)d VMX_INTR [ domid = 0x%(1)08x, trap = 0x%(2)08x, va = 0x%(3)08x ] 138.12 + 138.13 +0x00081001 CPU%(cpu)d %(tsc)d VMEXIT_0 0x%(1)08x 0x%(2)08x 0x%(3)08x 138.14 +0x00082001 CPU%(cpu)d %(tsc)d VMENTRY_0 0x%(1)08x 0x%(2)08x 0x%(3)08x 0x%(4)08x 0x%(5)08x 138.15 + 138.16 +0x00081002 CPU%(cpu)d %(tsc)d VMEXIT_1 0x%(1)08x 0x%(2)08x 0x%(3)08x 138.17 +0x00082002 CPU%(cpu)d %(tsc)d VMENTRY_1 0x%(1)08x 0x%(2)08x 0x%(3)08x 0x%(4)08x 0x%(5)08x 138.18 + 138.19 +0x00081003 CPU%(cpu)d %(tsc)d VMEXIT_2 0x%(1)08x 0x%(2)08x 0x%(3)08x 138.20 +0x00082003 CPU%(cpu)d %(tsc)d VMENTRY_2 0x%(1)08x 0x%(2)08x 0x%(3)08x 0x%(4)08x 0x%(5)08x 138.21 138.22 -0x00081001 CPU%(cpu)d %(tsc)d VMEXIT 0x%(1)08x 0x%(2)08x 0x%(3)08x 138.23 -0x00081002 CPU%(cpu)d %(tsc)d VMENTRY 0x%(1)08x 0x%(2)08x 0x%(3)08x 0x%(4)08x 0x%(5)08x 138.24 +0x00081004 CPU%(cpu)d %(tsc)d VMEXIT_3 0x%(1)08x 0x%(2)08x 0x%(3)08x 138.25 +0x00082004 CPU%(cpu)d %(tsc)d VMENTRY_3 0x%(1)08x 0x%(2)08x 0x%(3)08x 0x%(4)08x 0x%(5)08x 138.26 + 138.27 +0x00081005 CPU%(cpu)d %(tsc)d VMEXIT_4 0x%(1)08x 0x%(2)08x 0x%(3)08x 138.28 +0x00082005 CPU%(cpu)d %(tsc)d VMENTRY_4 0x%(1)08x 0x%(2)08x 0x%(3)08x 0x%(4)08x 0x%(5)08x 138.29 138.30 +0x00081006 CPU%(cpu)d %(tsc)d VMEXIT_5 0x%(1)08x 0x%(2)08x 0x%(3)08x 138.31 +0x00082006 CPU%(cpu)d %(tsc)d VMENTRY_5 0x%(1)08x 0x%(2)08x 0x%(3)08x 0x%(4)08x 0x%(5)08x 138.32 + 138.33 +0x00081007 CPU%(cpu)d %(tsc)d VMEXIT_6 0x%(1)08x 0x%(2)08x 0x%(3)08x 138.34 +0x00082007 CPU%(cpu)d %(tsc)d VMENTRY_6 0x%(1)08x 0x%(2)08x 0x%(3)08x 0x%(4)08x 0x%(5)08x 138.35 + 138.36 +0x00081008 CPU%(cpu)d %(tsc)d VMEXIT_7 0x%(1)08x 0x%(2)08x 0x%(3)08x 138.37 +0x00082008 CPU%(cpu)d %(tsc)d VMENTRY_7 0x%(1)08x 0x%(2)08x 0x%(3)08x 0x%(4)08x 0x%(5)08x
139.1 --- a/tools/xm-test/README Sun Oct 22 14:39:15 2006 -0600 139.2 +++ b/tools/xm-test/README Sun Oct 22 15:23:52 2006 -0600 139.3 @@ -112,6 +112,38 @@ Xm-test will look for disk.img in the ra 139.4 default. 139.5 139.6 139.7 +BUILDING for ACM Security Testing 139.8 +================================= 139.9 + 139.10 +A number of tests have been added to test the access control module (ACM) 139.11 +in the Xen hypervisor and the tools for supporting ACM. Those tests are 139.12 +located in the security-acm directory. If ACM support is compiled into Xen 139.13 +(see the user guide for how to do this) those tests can be run with the 139.14 +following command from the xm-test directory 139.15 + 139.16 +./runtest.sh [...] -g security <report> 139.17 + 139.18 +Some of these tests will work even without support of ACM by Xen. 139.19 + 139.20 +The xm test suite has been extended to support labeling of resources 139.21 +as required by the existing tests. However, by default the test suite 139.22 +is not allowed to automatically label resources since this may affect 139.23 +existing labels. To enable this, the test suite must be configured with 139.24 +the following parameter passed to the configure scripts (in addition to 139.25 +any other desired parameters) 139.26 + 139.27 +./configure --enable-full-labeling 139.28 + 139.29 +To revoke the privilege at a later time run the configure scripts without 139.30 +this parameter: 139.31 + 139.32 +./configure 139.33 + 139.34 +If a 'make' has previously been run for building the test suite, it is not 139.35 +necessary to run 'make' again just for enabling or disabling the automatic 139.36 +labeling of resources. 139.37 + 139.38 + 139.39 Running 139.40 ======= 139.41
140.1 --- a/tools/xm-test/configure.ac Sun Oct 22 14:39:15 2006 -0600 140.2 +++ b/tools/xm-test/configure.ac Sun Oct 22 15:23:52 2006 -0600 140.3 @@ -38,6 +38,20 @@ fi 140.4 AM_CONDITIONAL(HVM, test x$ENABLE_HVM = xTrue) 140.5 AC_SUBST(ENABLE_HVM) 140.6 140.7 +AC_ARG_ENABLE(full-labeling, 140.8 + [[ --enable-full-labeling allows the test suite to label all resources]], 140.9 + [ 140.10 + ENABLE_LABELING=True 140.11 + ],[ 140.12 + ENABLE_LABELING=False 140.13 + ]) 140.14 + 140.15 +if test "x$ENABLE_LABELING" = "xTrue"; then 140.16 + echo "ACM_LABEL_RESOURCES = True" > lib/XmTestLib/acm_config.py 140.17 +else 140.18 + rm -f lib/XmTestLib/acm_config.py* 140.19 +fi 140.20 + 140.21 # Network needs to know ips to use: dhcp or a range of IPs in the form 140.22 # of: 192.168.1.1-192.168.1.100 140.23 # If not dhcp, a netmask and network address must be supplied. Defaults to 140.24 @@ -127,6 +141,7 @@ AC_CONFIG_FILES([ 140.25 tests/restore/Makefile 140.26 tests/save/Makefile 140.27 tests/sched-credit/Makefile 140.28 + tests/security-acm/Makefile 140.29 tests/sedf/Makefile 140.30 tests/shutdown/Makefile 140.31 tests/sysrq/Makefile
141.1 --- a/tools/xm-test/grouptest/default Sun Oct 22 14:39:15 2006 -0600 141.2 +++ b/tools/xm-test/grouptest/default Sun Oct 22 15:23:52 2006 -0600 141.3 @@ -22,6 +22,7 @@ reboot 141.4 restore 141.5 save 141.6 sched-credit 141.7 +security-acm 141.8 shutdown 141.9 sysrq 141.10 unpause
142.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 142.2 +++ b/tools/xm-test/grouptest/security Sun Oct 22 15:23:52 2006 -0600 142.3 @@ -0,0 +1,1 @@ 142.4 +security-acm
143.1 --- a/tools/xm-test/lib/XmTestLib/XenDomain.py Sun Oct 22 14:39:15 2006 -0600 143.2 +++ b/tools/xm-test/lib/XmTestLib/XenDomain.py Sun Oct 22 15:23:52 2006 -0600 143.3 @@ -29,6 +29,7 @@ from Test import * 143.4 from config import * 143.5 from Console import * 143.6 from XenDevice import * 143.7 +from acm import * 143.8 143.9 BLOCK_ROOT_DEV = "hda" 143.10 143.11 @@ -102,6 +103,9 @@ class XenConfig: 143.12 self.defaultOpts["disk"] = [] 143.13 self.defaultOpts["vif"] = [] 143.14 self.defaultOpts["vtpm"] = [] 143.15 + if isACMEnabled(): 143.16 + #A default so every VM can start with ACM enabled 143.17 + self.defaultOpts["access_control"] = ['policy=xm-test,label=red'] 143.18 143.19 self.opts = self.defaultOpts 143.20 143.21 @@ -129,6 +133,7 @@ class XenConfig: 143.22 output = file(filename, "w") 143.23 output.write(self.toString()) 143.24 output.close() 143.25 + ACMPrepareSystem(self.opts) 143.26 143.27 def __str__(self): 143.28 """When used as a string, we represent ourself by a config
144.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 144.2 +++ b/tools/xm-test/lib/XmTestLib/acm.py Sun Oct 22 15:23:52 2006 -0600 144.3 @@ -0,0 +1,91 @@ 144.4 +#!/usr/bin/python 144.5 +""" 144.6 + Copyright (C) International Business Machines Corp., 2006 144.7 + Author: Stefan Berger <stefanb@us.ibm.com> 144.8 + 144.9 + This program is free software; you can redistribute it and/or modify 144.10 + it under the terms of the GNU General Public License as published by 144.11 + the Free Software Foundation; under version 2 of the License. 144.12 + 144.13 + This program is distributed in the hope that it will be useful, 144.14 + but WITHOUT ANY WARRANTY; without even the implied warranty of 144.15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 144.16 + GNU General Public License for more details. 144.17 + 144.18 + You should have received a copy of the GNU General Public License 144.19 + along with this program; if not, write to the Free Software 144.20 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 144.21 + 144.22 +""" 144.23 +from Test import * 144.24 +from xen.util import security 144.25 + 144.26 +try: 144.27 + from acm_config import * 144.28 +except: 144.29 + ACM_LABEL_RESOURCES = False 144.30 + 144.31 +labeled_resources = {} 144.32 +acm_verbose = True 144.33 + 144.34 +def isACMEnabled(): 144.35 + return security.on() 144.36 + 144.37 + 144.38 +def ACMLoadPolicy(policy='xm-test'): 144.39 + s, o = traceCommand("xm makepolicy %s" % (policy)) 144.40 + if s != 0: 144.41 + FAIL("Need to be able to do 'xm makepolicy %s' but could not" % 144.42 + (policy)) 144.43 + s, o = traceCommand("xm loadpolicy %s" % (policy)) 144.44 + if s != 0: 144.45 + FAIL("Could not load the required policy '%s'.\n" 144.46 + "Start the system without any policy.\n%s" % 144.47 + (policy, o)) 144.48 + 144.49 +def ACMPrepareSystem(resources): 144.50 + if isACMEnabled(): 144.51 + ACMLoadPolicy() 144.52 + ACMLabelResources(resources) 144.53 + 144.54 +def ACMLabelResources(resources): 144.55 + for k, v in resources.items(): 144.56 + if k == "disk": 144.57 + for vv in v: 144.58 + res = vv.split(',')[0] 144.59 + ACMLabelResource(res) 144.60 + 144.61 +# Applications may label resources explicitly by calling this function 144.62 +def ACMLabelResource(resource, label='red'): 144.63 + if acm_verbose: 144.64 + print "labeling resource %s with label %s" % (resource, label) 144.65 + if not ACM_LABEL_RESOURCES: 144.66 + SKIP("Skipping test since not allowed to label resources in " 144.67 + "test suite") 144.68 + if not isACMResourceLabeled(resource): 144.69 + ACMUnlabelResource(resource) 144.70 + s, o = traceCommand("xm addlabel %s res %s" % (label, resource)) 144.71 + if s != 0: 144.72 + FAIL("Could not add label to resource") 144.73 + else: 144.74 + labeled_resources["%s" % resource] = 1 144.75 + 144.76 + 144.77 +# Application may remove a label from a resource. It has to call this 144.78 +# function and must do so once a resource for re-labeling a resource 144.79 +def ACMUnlabelResource(resource): 144.80 + s, o = traceCommand("xm rmlabel res %s" % (resource)) 144.81 + labeled_resources["%s" % resource] = 0 144.82 + 144.83 + 144.84 +def isACMResourceLabeled(resource): 144.85 + """ Check whether a resource has been labeled using this API 144.86 + and while running the application """ 144.87 + try: 144.88 + if labeled_resources["%s" % resource] == 1: 144.89 + if acm_verbose: 144.90 + print "resource %s already labeled!" % resource 144.91 + return True 144.92 + except: 144.93 + return False 144.94 + return False
145.1 --- a/tools/xm-test/lib/XmTestLib/block_utils.py Sun Oct 22 14:39:15 2006 -0600 145.2 +++ b/tools/xm-test/lib/XmTestLib/block_utils.py Sun Oct 22 15:23:52 2006 -0600 145.3 @@ -6,6 +6,7 @@ 145.4 import time 145.5 145.6 from XmTestLib import * 145.7 +from acm import * 145.8 145.9 import xen.util.blkif 145.10 145.11 @@ -26,6 +27,7 @@ def get_state(domain, devname): 145.12 145.13 145.14 def block_attach(domain, phy, virt): 145.15 + ACMLabelResource(phy) 145.16 status, output = traceCommand("xm block-attach %s %s %s w" % 145.17 (domain.getName(), phy, virt)) 145.18 if status != 0:
146.1 --- a/tools/xm-test/runtest.sh Sun Oct 22 14:39:15 2006 -0600 146.2 +++ b/tools/xm-test/runtest.sh Sun Oct 22 15:23:52 2006 -0600 146.3 @@ -197,6 +197,8 @@ run=yes 146.4 unsafe=no 146.5 GROUPENTERED=default 146.6 146.7 +cp -f tests/security-acm/xm-test-security_policy.xml /etc/xen/acm-security/policies 146.8 + 146.9 # Resolve options 146.10 while [ $# -gt 0 ] 146.11 do
147.1 --- a/tools/xm-test/tests/Makefile.am Sun Oct 22 14:39:15 2006 -0600 147.2 +++ b/tools/xm-test/tests/Makefile.am Sun Oct 22 15:23:52 2006 -0600 147.3 @@ -19,6 +19,7 @@ SUBDIRS = \ 147.4 pause \ 147.5 reboot \ 147.6 sched-credit \ 147.7 + security-acm \ 147.8 sedf \ 147.9 shutdown \ 147.10 sysrq \
148.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 148.2 +++ b/tools/xm-test/tests/security-acm/01_security-acm_basic.py Sun Oct 22 15:23:52 2006 -0600 148.3 @@ -0,0 +1,121 @@ 148.4 +#!/usr/bin/python 148.5 + 148.6 +# Copyright (C) International Business Machines Corp., 2006 148.7 +# Author: Stefan Berger <stefanb@us.ibm.com> 148.8 +# 148.9 +# A couple of simple tests that test ACM security extensions 148.10 +# for the xm tool. The following xm subcommands are tested: 148.11 +# 148.12 +# - makepolicy 148.13 +# - labels 148.14 +# - rmlabel 148.15 +# - addlabel 148.16 +# - getlabel 148.17 +# - resources 148.18 + 148.19 +from XmTestLib import * 148.20 +from xen.util import security 148.21 +import commands 148.22 +import os 148.23 +import re 148.24 + 148.25 +testpolicy = "xm-test" 148.26 +testlabel = "blue" 148.27 +vmconfigfile = "/tmp/xm-test.conf" 148.28 +testresource = "phy:ram0" 148.29 + 148.30 +if not isACMEnabled(): 148.31 + SKIP("Not running this test since ACM not enabled.") 148.32 + 148.33 +status, output = traceCommand("xm makepolicy %s" % (testpolicy)) 148.34 +if status != 0 or output != "": 148.35 + FAIL("'xm makepolicy' failed with status %d and output\n%s" % 148.36 + (status,output)); 148.37 + 148.38 +status, output = traceCommand("xm labels %s" % (testpolicy)) 148.39 +if status != 0: 148.40 + FAIL("'xm labels' failed with status %d.\n" % status) 148.41 + 148.42 +#Need to get a vm config file - just have it written to a file 148.43 +domain = XmTestDomain() 148.44 +domain.config.write(vmconfigfile) 148.45 + 148.46 +#Whatever label it might have - remove it 148.47 +status, output = traceCommand("xm rmlabel dom %s" % 148.48 + (vmconfigfile)) 148.49 + 148.50 +status, output = traceCommand("xm addlabel %s dom %s %s" % 148.51 + (testlabel, vmconfigfile, testpolicy)) 148.52 +if status != 0: 148.53 + FAIL("'xm addlabel' failed with status %d.\n" % status) 148.54 + 148.55 +status, output = traceCommand("xm getlabel dom %s" % 148.56 + (vmconfigfile)) 148.57 + 148.58 +if status != 0: 148.59 + FAIL("'xm getlabel' failed with status %d, output:\n%s" % 148.60 + (status, output)) 148.61 +if output != "policy=%s,label=%s" % (testpolicy,testlabel): 148.62 + FAIL("Received unexpected output from 'xm getlabel': \n%s" % 148.63 + (output)) 148.64 + 148.65 + 148.66 +status, output = traceCommand("xm rmlabel dom %s" % 148.67 + (vmconfigfile)) 148.68 + 148.69 +if status != 0: 148.70 + FAIL("'xm rmlabel' failed with status %d, output: \n%s" % 148.71 + (status,output)) 148.72 +if output != "": 148.73 + FAIL("Received unexpected output from 'xm rmlabel': \n%s" % 148.74 + (output))