Skip to contentSkip to conversation

x86_64: interface structure translation abstraction

RFC PATCH New Jan Beulich 1 participant 1 message Aug 25, 2006

lore
Share & tools
lore
#0 lore raw

RFC PATCH 4/4 x86_64: interface structure translation abstraction

This introduces
- a mechanism to auto-generate (most of) the code needed to translate structures between their native and compatibility variants
- the first few uses of this to setup appropriate startup info for a compatibility mode guest

Config.mk +2 -0
Index: 2006-08-16/Config.mk
===================================================================
@@ -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
xen/arch/x86/domain_build.c +10 -0
Index: 2006-08-16/xen/arch/x86/domain_build.c
===================================================================
@@ -19,6 +19,7 @@
 #include <xen/version.h>
 #include <xen/iocap.h>
 #include <xen/bitops.h>
+#include <xen/compat.h>
 #include <asm/regs.h>
 #include <asm/system.h>
 #include <asm/io.h>
@@ -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();
xen/arch/x86/setup.c +12 -0
Index: 2006-08-16/xen/arch/x86/setup.c
===================================================================
@@ -16,6 +16,10 @@
 #include <xen/gdbstub.h>
 #include <xen/percpu.h>
 #include <public/version.h>
+#ifdef CONFIG_COMPAT
+#include <compat/dom0_ops.h>
+#include <compat/xen.h>
+#endif
 #include <asm/bitops.h>
 #include <asm/smp.h>
 #include <asm/processor.h>
@@ -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
xen/include/Makefile +8 -0
Index: 2006-08-16/xen/include/Makefile
===================================================================
@@ -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 <xlat.lst >[email protected]
+	mv -f [email protected] $@
+
 clean::
 	rm -rf compat
xen/include/xlat.lst new file +2 -0
Index: 2006-08-16/xen/include/xlat.lst
===================================================================
@@ -0,0 +1,2 @@
+start_info			xen.h
+dom0_vga_console_info		xen.h
xen/tools/get-fields.sh new file +240 -0

240 lines not on this page · raw message

xen/common/compat/Makefile +1 -0
Index: 2006-08-16/xen/common/compat/Makefile
===================================================================
@@ -1 +1,2 @@
+obj-y += xlat.o
 obj-y += kernel.o
xen/common/compat/xlat.c new file +38 -0
Index: 2006-08-16/xen/common/compat/xlat.c
===================================================================
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * xlat.c
+ */
+
+#include <xen/compat.h>
+#include <xen/lib.h>
+#include <public/xen.h>
+#include <compat/xen.h>
+
+/* 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:
+ */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel