Index: 2006-08-16/Config.mk =================================================================== --- 2006-08-16.orig/Config.mk 2006-08-25 15:32:03.000000000 +0200 +++ 2006-08-16/Config.mk 2006-08-25 15:33:34.000000000 +0200 @@ -8,6 +8,8 @@ XEN_COMPILE_ARCH ?= $(shell uname -m XEN_TARGET_ARCH ?= $(XEN_COMPILE_ARCH) XEN_TARGET_X86_PAE ?= n +SHELL ?= /bin/sh + # Tools to run on system hosting the build HOSTCC = gcc HOSTCFLAGS = -Wall -Werror -Wstrict-prototypes -O2 -fomit-frame-pointer Index: 2006-08-16/xen/arch/x86/domain_build.c =================================================================== --- 2006-08-16.orig/xen/arch/x86/domain_build.c 2006-08-25 15:32:03.000000000 +0200 +++ 2006-08-16/xen/arch/x86/domain_build.c 2006-08-25 15:33:34.000000000 +0200 @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -823,6 +824,15 @@ int construct_dom0(struct domain *d, si->console.dom0.info_size = sizeof(struct dom0_vga_console_info); } +#ifdef CONFIG_COMPAT + if ( IS_COMPAT(d) ) + { + if ( si->console.dom0.info_size ) + si->console.dom0.info_size = xlat_dom0_vga_console_info((void *)(si + 1)); + xlat_start_info(si, XLAT_start_info_console_domU); + } +#endif + /* Reinstate the caller's page tables. */ write_ptbase(current); local_irq_enable(); Index: 2006-08-16/xen/arch/x86/setup.c =================================================================== --- 2006-08-16.orig/xen/arch/x86/setup.c 2006-08-25 15:32:03.000000000 +0200 +++ 2006-08-16/xen/arch/x86/setup.c 2006-08-25 15:33:34.000000000 +0200 @@ -16,6 +16,10 @@ #include #include #include +#ifdef CONFIG_COMPAT +#include +#include +#endif #include #include #include @@ -396,6 +400,14 @@ void __init __start_xen(multiboot_info_t BUILD_BUG_ON(sizeof(shared_info_t) > PAGE_SIZE); BUILD_BUG_ON(sizeof(vcpu_info_t) != 64); +#ifdef CONFIG_COMPAT + BUILD_BUG_ON(sizeof(((struct compat_dom0_op *)0)->u) != + sizeof(((struct compat_dom0_op *)0)->u.pad)); + BUILD_BUG_ON(sizeof(start_info_compat_t) > PAGE_SIZE); + BUILD_BUG_ON(sizeof(shared_info_compat_t) > PAGE_SIZE); + BUILD_BUG_ON(sizeof(vcpu_info_compat_t) != 64); +#endif + /* Check definitions in public headers match internal defs. */ BUILD_BUG_ON(__HYPERVISOR_VIRT_START != HYPERVISOR_VIRT_START); #ifdef HYPERVISOR_VIRT_END Index: 2006-08-16/xen/include/Makefile =================================================================== --- 2006-08-16.orig/xen/include/Makefile 2006-08-25 15:33:32.000000000 +0200 +++ 2006-08-16/xen/include/Makefile 2006-08-25 15:33:34.000000000 +0200 @@ -2,6 +2,7 @@ ifneq ($(CONFIG_COMPAT),) headers-y := $(shell find public -name '*.h' -not -name '*-*' | sed 's,^public,compat,') headers-$(CONFIG_X86) += compat/arch-x86_32.h +headers-y += compat/xlat.h cppflags-y := -include public/xen-compat.h cppflags-$(CONFIG_X86) += -m32 @@ -49,5 +50,12 @@ compat/%.c: public/%.h Makefile -e 's,XEN_GUEST_HANDLE,COMPAT_HANDLE,g' \ >$@ +compat/xlat.h: xlat.lst $(filter-out compat/xlat.h,$(headers-y)) $(BASEDIR)/tools/get-fields.sh Makefile + set -e; \ + while read name hdr; do \ + $(SHELL) $(BASEDIR)/tools/get-fields.sh compat_$$name compat/$$hdr; \ + done $@.new + mv -f $@.new $@ + clean:: rm -rf compat Index: 2006-08-16/xen/include/xlat.lst =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ 2006-08-16/xen/include/xlat.lst 2006-08-25 15:33:34.000000000 +0200 @@ -0,0 +1,2 @@ +start_info xen.h +dom0_vga_console_info xen.h Index: 2006-08-16/xen/tools/get-fields.sh =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ 2006-08-16/xen/tools/get-fields.sh 2006-08-25 15:33:34.000000000 +0200 @@ -0,0 +1,240 @@ +#!/bin/sh +test -n "$1" -a -n "$2" +set -ef + +get_fields() { + local level=1 aggr=0 name= fields= + for token in $2 + do + case "$token" in + struct|union) + test $level != 1 || aggr=1 fields= name= + ;; + "{") + level=$(expr $level + 1) + ;; + "}") + level=$(expr $level - 1) + if [ $level = 1 -a $name = $1 ] + then + echo "$fields }" + return 0 + fi + ;; + [[:alpha:]_]*) + test $aggr = 0 -o -n "$name" || name="$token" + ;; + esac + test $aggr = 0 || fields="$fields $token" + done +} + +build_enums() { + local level=1 kind= fields= members= named= id= token + for token in $2 + do + case "$token" in + struct|union) + test $level != 2 || fields=" " + kind="$token;$kind" + ;; + "{") + level=$(expr $level + 1) + ;; + "}") + level=$(expr $level - 1) + if [ $level = 1 ] + then + if [ "${kind%%;*}" = union ] + then + echo + echo "enum XLAT_$1 {" + for m in $members + do + echo " XLAT_${1}_$m," + done + echo "};" + fi + return 0 + elif [ $level = 2 ] + then + named='?' + fi + ;; + [[:alpha:]]*) + id=$token + if [ -n "$named" -a -n "${kind#*;}" ] + then + build_enums ${1}_$token "$fields" + named='!' + fi + ;; + ",") + test $level != 2 || members="$members $id" + ;; + ";") + test $level != 2 || members="$members $id" + test -z "$named" || kind=${kind#*;} + named= + ;; + esac + test -z "$fields" || fields="$fields $token" + done +} + +handle_field() { + if [ -z "$4" ] + then + echo " \\" + echo -n "$1(_d_)->$3 = (_s_)->$3;" + elif [ -z "$(echo "$4" | sed 's,[^{}],,g')" ] + then + local tag=$(echo "$4" | sed 's,[[:space:]]*\(struct\|union\)[[:space:]]\+\(compat_\)\?\([[:alnum:]_]\+\)[[:space:]].*,\3,') + echo " \\" + echo -n "${1}XLAT_$tag(&(_d_)->$3, &(_s_)->$3);" + else + local level=1 kind= fields= id= token + for token in $4 + do + case "$token" in + struct|union) + test $level != 2 || fields=" " + if [ $level == 1 ] + then + kind=$token + if [ $kind = union ] + then + echo " \\" + echo -n "${1}switch ($(echo $3 | sed 's,\.,_,g')) {" + fi + fi + ;; + "{") + level=$(expr $level + 1) + ;; + "}") + level=$(expr $level - 1) + if [ $level == 1 -a $kind = union ] + then + echo " \\" + echo -n "$1}" + fi + ;; + [[:alpha:]]*) + id=$token + ;; + [\,\;]) + if [ $level == 2 ] + then + if [ $kind = union ] + then + echo " \\" + echo -n "${1}case XLAT_${2}_$(echo $3.$id | sed 's,\.,_,g'):" + handle_field "$1 " $2 $3.$id "$fields" + else + handle_field "$1" $2 $3.$id "$fields" + fi + test "$token" != ";" || fields= + if [ $kind = union ] + then + echo " \\" + echo -n "$1 break;" + fi + fi + ;; + esac + test -z "$fields" || fields="$fields $token" + done + fi +} + +handle_array() { + local i="i$(echo $4 | sed 's,[^;], ,g' | wc -w)" + echo " \\" + echo "$1{ \\" + echo "$1 unsigned long $i; \\" + echo -n "$1 for ($i = 0; $i < "${4%%;*}"; ++$i) {" + if [ "$4" = "${4#*;}" ] + then + handle_field "$1 " $2 $3[$i] "$5" + else + handle_array "$1 " $2 $3[$i] "${4#*;}" "$5" + fi + echo " \\" + echo "$1 } \\" + echo -n "$1}" +} + +build_body() { + echo + echo -n "#define XLAT_$1(_d_, _s_)" + local level=1 fields= id= array= arrlvl=1 token + for token in $2 + do + case "$token" in + struct|union) + test $level != 2 || fields=" " + ;; + "{") + level=$(expr $level + 1) + ;; + "}") + level=$(expr $level - 1) + ;; + "[") + if [ $arrlvl != 1 ] + then + : + elif [ -z "$array" ] + then + array=" " + else + array="$array;" + fi + arrlvl=$(expr $arrlvl + 1) + ;; + "]") + arrlvl=$(expr $arrlvl - 1) + ;; + [[:alpha:]]*) + if [ $level == 2 -a -n "$array" ] + then + array="$array $token" + else + id=$token + array= + fi + ;; + [[:digit:]]*|0[xX][[:xdigit:]]*) + if [ $level == 2 -a -n "$array" ] + then + array="$array $token" + fi + ;; + [\,\;]) + if [ $level == 2 ] + then + if [ -z "$array" ] + then + handle_field " " $1 $id "$fields" + else + handle_array " " $1 $id "${array#*;}" "$fields" + fi + test "$token" != ";" || fields= array= + fi + ;; + *) + if [ $level == 2 -a -n "$array" ] + then + array="$array $token" + fi + ;; + esac + test -z "$fields" || fields="$fields $token" + done + echo "" +} + +fields="$(get_fields $1 "$(sed -e 's,^[[:space:]]#.*,,' -e 's!\([]\[,;:{}]\)! \1 !g' $2)")" +build_enums ${1#compat_} "$fields" +build_body ${1#compat_} "$fields" Index: 2006-08-16/xen/common/compat/Makefile =================================================================== --- 2006-08-16.orig/xen/common/compat/Makefile 2006-08-25 15:33:32.000000000 +0200 +++ 2006-08-16/xen/common/compat/Makefile 2006-08-25 15:33:34.000000000 +0200 @@ -1 +1,2 @@ +obj-y += xlat.o obj-y += kernel.o Index: 2006-08-16/xen/common/compat/xlat.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ 2006-08-16/xen/common/compat/xlat.c 2006-08-25 15:33:34.000000000 +0200 @@ -0,0 +1,38 @@ +/****************************************************************************** + * xlat.c + */ + +#include +#include +#include +#include + +/* In-place translation functons: */ +void xlat_start_info(struct start_info *native, + enum XLAT_start_info_console console) +{ + struct compat_start_info *compat = (void *)native; + + BUILD_BUG_ON(sizeof(*native) < sizeof(*compat)); + XLAT_start_info(compat, native); +} + +size_t xlat_dom0_vga_console_info(struct dom0_vga_console_info *native) +{ + struct compat_dom0_vga_console_info *compat = (void *)native; + + BUILD_BUG_ON(sizeof(*native) < sizeof(*compat)); + XLAT_dom0_vga_console_info(compat, native); + return sizeof(*compat); +} + + +/* + * Local variables: + * mode: C + * c-set-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */