Skip to contentSkip to conversation

Fix __XEN_INTERFACE_VERSION__ old config breakage

PATCH In review Magnus Damm 4 participants 9 messages Apr 4, 2006 – Apr 7, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix __XEN_INTERFACE_VERSION__ old config breakage

Fix __XEN_INTERFACE_VERSION__ old config breakage

For old kernel configurations that lack CONFIG_XEN_INTERFACE_VERSION, __XEN_INTERFACE_VERSION__ will currently be defined but set to nothing.

If a xen-enabled kernel is built separately from the xen-unstable dist, the following error occurs with xen-unstable-9415:

#

# using defaults found in .config
#
  SPLIT   include/linux/autoconf.h -> include/config/*
  CC      arch/i386/kernel/asm-offsets.s
In file included from include/xen/interface/xen.h:439,
                 from include/asm/mach-xen/asm/page.h:20,
                 from include/asm/thread_info.h:14,
                 from include/linux/thread_info.h:21,
                 from include/linux/preempt.h:10,
                 from include/linux/spinlock.h:50,
                 from include/linux/capability.h:45,
                 from include/linux/sched.h:7,
                 from arch/i386/kernel/asm-offsets.c:7:
include/xen/interface/xen-compat.h:22:31: #if with no expression
include/xen/interface/xen-compat.h:26:31: #if with no expression
make[1]: *** [arch/i386/kernel/asm-offsets.s] Error 1
make: *** [prepare0] Error 2
$

The patch below fixes the problem and makes the logic in xen-compat.h work correctly - __XEN_INTERFACE_VERSION__ now becomes unset if the config option is missing.

arch/i386/Makefile +2 -0
@@ -45,8 +45,10 @@ CFLAGS				+= $(shell if [ $(call cc-vers
 
 CFLAGS += $(cflags-y)
 
+ifneq   "$(CONFIG_XEN_INTERFACE_VERSION)" ""
 cppflags-$(CONFIG_XEN) += \
 	-D__XEN_INTERFACE_VERSION__=$(CONFIG_XEN_INTERFACE_VERSION)
+endif
 
 CPPFLAGS += $(cppflags-y)
#1 lore raw
Quoted 7 lines · Magnus Damm

Fix __XEN_INTERFACE_VERSION__ old config breakage

For old kernel configurations that lack CONFIG_XEN_INTERFACE_VERSION, __XEN_INTERFACE_VERSION__ will currently be defined but set to nothing.

If a xen-enabled kernel is built separately from the xen-unstable dist, the following error occurs with xen-unstable-9415:

I don't think this will work, since the interface version will be set to 0 by xen-compat.h, but the current Linux kernel patches want to build against interface version 0x00030101. Just run 'make oldconfig' to update your .config file with the correct definition of CONFIG_XEN_INTERFACE_VERSION.

-- Keir

#2 lore raw
In reply to Magnus Damm
Quoted 4 lines · Magnus Damm

Fix __XEN_INTERFACE_VERSION__ old config breakage

For old kernel configurations that lack CONFIG_XEN_INTERFACE_VERSION, __XEN_INTERFACE_VERSION__ will currently be defined but set to nothing.

I've checked in a change to xen-compat.h which handles this case.

christian

# HG changeset patch
# User [email protected]
# Date Thu Apr 6 23:32:54 2006
# Node ID 0010df11836d182fbb00ebcc016e9e51705470e0
# parent: b6c5920e5d998d8055a8b2f540462ace3e860d99 Support __XEN_INTERFACE_VERSION__ defined to the empty string. This can happen when building Linux with an old .config file which doesn't have a value for CONFIG_XEN_INTERFACE_VERSION.

xen/include/public/xen-compat.h +4 -1
@@ -14,8 +14,11 @@
 #if defined(__XEN__)
 /* Xen is built with matching headers and implements the latest interface. */
 #define __XEN_INTERFACE_VERSION__ __XEN_LATEST_INTERFACE_VERSION__
-#elif !defined(__XEN_INTERFACE_VERSION__)
+#elif (__XEN_INTERFACE_VERSION__ - 0) == 0
 /* Guests which do not specify a version get the legacy interface. */
+#ifdef __XEN_INTERFACE_VERSION__
+#undef __XEN_INTERFACE_VERSION__
+#endif
 #define __XEN_INTERFACE_VERSION__ 0x00000000
 #endif
 

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

#3 lore raw
Quoted 7 lines · Christian Limpach
Quoted 4 lines · Magnus Damm

Fix __XEN_INTERFACE_VERSION__ old config breakage

For old kernel configurations that lack CONFIG_XEN_INTERFACE_VERSION, __XEN_INTERFACE_VERSION__ will currently be defined but set to nothing.

I've checked in a change to xen-compat.h which handles this case.

Very good. A much cleaner solution too. Thanks!

/ magnus

#4 lore raw
Quoted 9 lines · Magnus Damm
Quoted 7 lines · Magnus Damm
Quoted 4 lines

Fix __XEN_INTERFACE_VERSION__ old config breakage

For old kernel configurations that lack CONFIG_XEN_INTERFACE_VERSION, __XEN_INTERFACE_VERSION__ will currently be defined but set to nothing.

I've checked in a change to xen-compat.h which handles this case.

Very good. A much cleaner solution too. Thanks!

Does this lead to a kernel that actually works (e.g., can you sgut it down without crashing)? I doubt it.

-- Keir

#5 lore raw
Quoted 10 lines · Keir Fraser
Quoted 7 lines · Magnus Damm
Quoted 7 lines · Magnus Damm
Quoted 5 lines

Fix __XEN_INTERFACE_VERSION__ old config breakage

For old kernel configurations that lack CONFIG_XEN_INTERFACE_VERSION, __XEN_INTERFACE_VERSION__ will currently be defined but set to nothing.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I've checked in a change to xen-compat.h which handles this case.

Very good. A much cleaner solution too. Thanks!

Does this lead to a kernel that actually works (e.g., can you sgut it down without crashing)? I doubt it.

I use a kernel config without CONFIG_XEN_INTERFACE_VERSION, and building and running dom0 on x86 (in qemu) seems ok to me.

/ magnus

#6 lore raw
Quoted 5 lines · Magnus Damm
Quoted 2 lines

Does this lead to a kernel that actually works (e.g., can you sgut it down without crashing)? I doubt it.

I use a kernel config without CONFIG_XEN_INTERFACE_VERSION, and building and running dom0 on x86 (in qemu) seems ok to me.

I tried 'xm save' on such a domU and that doesn't work. The reason is that the kernel tree expects to be calling the new sched_op hypercall, but because the interface version gets defined to zero, it actually calls the old sched_op hypercall which takes different arguments. I also tried rebooting such a domU and that doesn't work (the guest is killed but not restarted) -- again because the old and new sched_op hypercall take their arguments in different ways.

These problems are somewhat hidden I suppose, since you can boot and run happily with the domain for the most part, but it illustrates that if a guest is defining an obviously interface version we should fail the build, not build some inconsistent combination of guest kernel and hypervisor interface!

-- Keir

#7 lore raw
Quoted 9 lines · Keir Fraser
Quoted 5 lines · Magnus Damm
Quoted 2 lines

Does this lead to a kernel that actually works (e.g., can you sgut it down without crashing)? I doubt it.

I use a kernel config without CONFIG_XEN_INTERFACE_VERSION, and building and running dom0 on x86 (in qemu) seems ok to me.

Quoted 7 lines

I tried 'xm save' on such a domU and that doesn't work. The reason is that the kernel tree expects to be calling the new sched_op hypercall, but because the interface version gets defined to zero, it actually calls the old sched_op hypercall which takes different arguments. I also tried rebooting such a domU and that doesn't work (the guest is killed but not restarted) -- again because the old and new sched_op hypercall take their arguments in different ways.

Oh, I see. I did not test _that_ much. Good that you noticed.

Quoted 5 lines

These problems are somewhat hidden I suppose, since you can boot and run happily with the domain for the most part, but it illustrates that if a guest is defining an obviously interface version we should fail the build, not build some inconsistent combination of guest kernel and hypervisor interface!

I'm afraid that I know too little about xen to say something about how multiple interface versions are supposed to work, but I think your plan of failing instead of building an inconsistent kernel sounds good.

My main concern was that the code didn't build with my old config file, and the error message produced by the c-compiler was far from user friendly. If the kernel build should fail then I would prefer some see some kind of #error message.

Thanks!

/ magnus

#8 lore raw
Quoted 11 lines · Magnus Damm

I'm afraid that I know too little about xen to say something about how multiple interface versions are supposed to work, but I think your plan of failing instead of building an inconsistent kernel sounds good.

My main concern was that the code didn't build with my old config file, and the error message produced by the c-compiler was far from user friendly. If the kernel build should fail then I would prefer some see some kind of #error message.

Thanks!

Yes, that would be nice and preferably generated from within xen-compat.h so the check is not specific to Linux. But I'm not sure whether it's possible to detect an empty macro definition from CPP?

-- Keir