From: jbeulich@suse.com
Subject: add symbols to hypercall stubs
Patch-mainline: n/a

--- sle11sp3.orig/arch/x86/Makefile	2013-03-07 16:22:23.000000000 +0100
+++ sle11sp3/arch/x86/Makefile	2013-03-07 16:26:05.000000000 +0100
@@ -165,6 +165,20 @@ ifdef CONFIG_X86_64
 LDFLAGS_vmlinux := -e startup_64
 endif
 
+quiet_cmd_hypercalls = HYPERCALLS $(patsubst $(objtree)/%,%,$@)
+      cmd_hypercalls = $(CONFIG_SHELL) '$<' $@ $(filter %.h,$^)
+
+$(objtree)/arch/x86/include/generated/asm/%-hypercalls.h: $(srctree)/scripts/%-hypercalls.sh asm-generic
+	$(call if_changed,hypercalls)
+
+targets += $(objtree)/arch/x86/include/generated/asm/*-hypercalls.h
+
+$(objtree)/arch/x86/include/generated/asm/xen-hypercalls.h: \
+	$(srctree)/include/xen/interface/xen.h \
+	$(srctree)/include/xen/interface/arch-x86/xen*.h
+
+archprepare: $(objtree)/arch/x86/include/generated/asm/xen-hypercalls.h
+
 # Default kernel to build
 all: vmlinuz
 
--- sle11sp3.orig/arch/x86/kernel/head_32-xen.S	2013-03-07 16:22:22.000000000 +0100
+++ sle11sp3/arch/x86/kernel/head_32-xen.S	2012-12-04 15:13:42.000000000 +0100
@@ -15,6 +15,7 @@
 #include <asm/dwarf2.h>
 #include <asm/percpu.h>
 #include <xen/interface/xen.h>
+#include <xen/interface/arch-x86/xen-mca.h>
 #include <xen/interface/elfnote.h>
 #include <xen/interface/features.h>
 
@@ -110,8 +111,13 @@ ENTRY(startup_32)
 	pushl $0		# fake return address for unwinder
 	jmp i386_start_kernel
 
+#if CONFIG_XEN_COMPAT <= 0x030002
 #define HYPERCALL_PAGE_OFFSET 0x1000
 .org HYPERCALL_PAGE_OFFSET
+#else
+	.text
+	.balign PAGE_SIZE
+#endif
 ENTRY(hypercall_page)
 	CFI_STARTPROC
 	.skip __HYPERVISOR_iret * 32
@@ -123,6 +129,12 @@ ENTRY(hypercall_page)
 	.balign 0x1000,0
 	CFI_ENDPROC
 
+#define HYPERCALL(n) \
+	.equ HYPERVISOR_##n, hypercall_page + __HYPERVISOR_##n * 32; \
+	.type HYPERVISOR_##n, function; .size HYPERVISOR_##n, 32
+#include <asm/xen-hypercalls.h>
+#undef HYPERCALL
+
 /*
  * BSS section
  */
--- sle11sp3.orig/arch/x86/kernel/head_64-xen.S	2013-03-07 16:22:23.000000000 +0100
+++ sle11sp3/arch/x86/kernel/head_64-xen.S	2013-03-07 16:26:09.000000000 +0100
@@ -22,6 +22,7 @@
 #include <asm/dwarf2.h>
 #include <asm/percpu.h>
 #include <xen/interface/xen.h>
+#include <xen/interface/arch-x86/xen-mca.h>
 #include <xen/interface/elfnote.h>
 #include <xen/interface/features.h>
 
@@ -83,9 +84,15 @@ NEXT_PAGE(level2_fixmap_pgt)
 NEXT_PAGE(level1_fixmap_pgt)
 	.fill	512,8,0
 
+#if CONFIG_XEN_COMPAT <= 0x030002
 	.previous
+#else
+	.text
+#endif
 NEXT_PAGE(hypercall_page)
+#if CONFIG_XEN_COMPAT <= 0x030002
 	phys_hypercall_page = . - .head.text
+#endif
 	CFI_STARTPROC
 	i = 0
 	.rept 0x1000 / 0x20
@@ -120,6 +127,12 @@ NEXT_PAGE(hypercall_page)
 	.endr
 	CFI_ENDPROC
 
+#define HYPERCALL(n) \
+	.equ HYPERVISOR_##n, hypercall_page + __HYPERVISOR_##n * 32; \
+	.type HYPERVISOR_##n, function; .size HYPERVISOR_##n, 32
+#include <asm/xen-hypercalls.h>
+#undef HYPERCALL
+
 #undef NEXT_PAGE
 
 	__PAGE_ALIGNED_BSS
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ sle11sp3/scripts/xen-hypercalls.sh	2012-11-23 15:04:56.000000000 +0100
@@ -0,0 +1,9 @@
+#!/bin/sh
+out="$1"
+shift
+in="$@"
+
+for i in $in; do
+	$CPP -dD -imacros $i -x c /dev/null
+done | sed -n 's,#define __HYPERVISOR_\([a-z0-9_]*\)[[:space:]]\+\(__HYPERVISOR_arch_\)\?[0-9].*,HYPERCALL(\1),p' \
+     | grep -v '(arch_[0-9]\+)' | sort | uniq >$out
