[IA64] Kexec: is for privelaged guests only

This changes much usage of #ifdef CONFIG_XEN to
#ifdef CONFIG_XEN_PRIVILEGED_GUEST as the code is not
applicable to unprivelaged guests.

Its also fixes the KEXEC Kconfig option, so that
it is not available to unprivelaged guests.

Signed-off-by: Simon Horman <horms@verge.net.au>

Index: linux-2.6.18-xen.hg/arch/ia64/kernel/efi.c
===================================================================
--- linux-2.6.18-xen.hg.orig/arch/ia64/kernel/efi.c	2008-02-06 14:38:19.000000000 +0900
+++ linux-2.6.18-xen.hg/arch/ia64/kernel/efi.c	2008-02-06 14:39:51.000000000 +0900
@@ -1137,7 +1137,7 @@ efi_initialize_resources(void *efi_map_s
 				insert_resource(res, &boot_param_res);
 				if (crashk_res.end > crashk_res.start)
 					insert_resource(res, &crashk_res);
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 				if (is_initial_xendomain())
 					xen_machine_kexec_register_resources(
 								res);
Index: linux-2.6.18-xen.hg/arch/ia64/kernel/machine_kexec.c
===================================================================
--- linux-2.6.18-xen.hg.orig/arch/ia64/kernel/machine_kexec.c	2008-02-06 14:38:19.000000000 +0900
+++ linux-2.6.18-xen.hg/arch/ia64/kernel/machine_kexec.c	2008-02-06 14:39:51.000000000 +0900
@@ -18,7 +18,7 @@
 #include <asm/setup.h>
 #include <asm/delay.h>
 #include <asm/meminit.h>
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 #include <xen/interface/kexec.h>
 #include <asm/kexec.h>
 #endif
@@ -69,7 +69,7 @@ void machine_kexec_cleanup(struct kimage
 {
 }
 
-#ifndef CONFIG_XEN
+#ifndef CONFIG_XEN_PRIVILEGED_GUEST
 void machine_shutdown(void)
 {
 	int cpu;
@@ -136,10 +136,10 @@ void machine_kexec(struct kimage *image)
 	unw_init_running(ia64_machine_kexec, image);
 	for(;;);
 }
-#else /* CONFIG_XEN */
+#else /* CONFIG_XEN_PRIVILEGED_GUEST */
 void machine_kexec_setup_load_arg(xen_kexec_image_t *xki,struct kimage *image)
 {
 	xki->reboot_code_buffer =
 		kexec_page_to_pfn(image->control_code_page) << PAGE_SHIFT;
 }
-#endif /* CONFIG_XEN */
+#endif /* CONFIG_XEN_PRIVILEGED_GUEST */
Index: linux-2.6.18-xen.hg/arch/ia64/kernel/setup.c
===================================================================
--- linux-2.6.18-xen.hg.orig/arch/ia64/kernel/setup.c	2008-02-06 14:38:19.000000000 +0900
+++ linux-2.6.18-xen.hg/arch/ia64/kernel/setup.c	2008-02-06 14:39:51.000000000 +0900
@@ -307,7 +307,7 @@ reserve_memory (void)
 	{
 		char *from = strstr(saved_command_line, "crashkernel=");
 		unsigned long base, size;
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 		if (is_initial_xendomain() && from)
 				printk("Ignoring crashkernel command line, "
 				       "parameter will be supplied by xen\n");
@@ -336,7 +336,7 @@ reserve_memory (void)
 				}
 			}
 		}
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 		}
 #endif
 		efi_memmap_res.start = ia64_boot_param->efi_memmap;
Index: linux-2.6.18-xen.hg/arch/ia64/mm/contig.c
===================================================================
--- linux-2.6.18-xen.hg.orig/arch/ia64/mm/contig.c	2008-02-06 14:38:19.000000000 +0900
+++ linux-2.6.18-xen.hg/arch/ia64/mm/contig.c	2008-02-06 14:39:51.000000000 +0900
@@ -18,7 +18,7 @@
 #include <linux/efi.h>
 #include <linux/mm.h>
 #include <linux/swap.h>
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 #include <linux/kexec.h>
 #endif
 
@@ -175,7 +175,7 @@ find_memory (void)
 	/* Free all available memory, then mark bootmem-map as being in use. */
 	efi_memmap_walk(filter_rsvd_memory, free_bootmem);
 	reserve_bootmem(bootmap_start, bootmap_size);
-#if defined(CONFIG_XEN) && defined(CONFIG_KEXEC)
+#if defined(CONFIG_XEN_PRIVILEGED_GUEST) && defined(CONFIG_KEXEC)
 	xen_machine_kexec_setup_resources();
 #endif
 
Index: linux-2.6.18-xen.hg/fs/Kconfig
===================================================================
--- linux-2.6.18-xen.hg.orig/fs/Kconfig	2008-02-06 14:38:19.000000000 +0900
+++ linux-2.6.18-xen.hg/fs/Kconfig	2008-02-06 14:39:51.000000000 +0900
@@ -828,7 +828,7 @@ config PROC_VMCORE
 
 config PROC_IOMEM_MACHINE
 	bool
-	depends on PROC_FS && EXPERIMENTAL && KEXEC && XEN && IA64
+	depends on PROC_FS && EXPERIMENTAL && KEXEC && XEN_PRIVILEGED_GUEST && IA64
 	default y
 
 config SYSFS
Index: linux-2.6.18-xen.hg/include/asm-ia64/kexec.h
===================================================================
--- linux-2.6.18-xen.hg.orig/include/asm-ia64/kexec.h	2008-02-06 14:38:19.000000000 +0900
+++ linux-2.6.18-xen.hg/include/asm-ia64/kexec.h	2008-02-06 14:39:51.000000000 +0900
@@ -47,7 +47,7 @@ extern atomic_t kdump_in_progress;
 /* Kexec needs to know about the actual physical addresss.
  * But in xen, on some architectures, a physical address is a
  * pseudo-physical addresss. */
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 #define KEXEC_ARCH_HAS_PAGE_MACROS
 #define kexec_page_to_pfn(page)  pfn_to_mfn_for_dma(page_to_pfn(page))
 #define kexec_pfn_to_page(pfn)   pfn_to_page(mfn_to_pfn_for_dma(pfn))
Index: linux-2.6.18-xen.hg/include/linux/ioport.h
===================================================================
--- linux-2.6.18-xen.hg.orig/include/linux/ioport.h	2008-02-06 14:38:19.000000000 +0900
+++ linux-2.6.18-xen.hg/include/linux/ioport.h	2008-02-06 14:39:51.000000000 +0900
@@ -93,7 +93,7 @@ struct resource_list {
 /* PC/ISA/whatever - the normal PC address spaces: IO and memory */
 extern struct resource ioport_resource;
 extern struct resource iomem_resource;
-#ifdef CONFIG_XEN
+#ifdef CONFIG_PROC_IOMEM_MACHINE
 extern struct resource iomem_machine_resource;
 #endif
 
Index: linux-2.6.18-xen.hg/arch/ia64/Kconfig
===================================================================
--- linux-2.6.18-xen.hg.orig/arch/ia64/Kconfig	2008-02-06 14:38:19.000000000 +0900
+++ linux-2.6.18-xen.hg/arch/ia64/Kconfig	2008-02-06 14:39:51.000000000 +0900
@@ -459,7 +459,7 @@ source "drivers/sn/Kconfig"
 
 config KEXEC
 	bool "kexec system call (EXPERIMENTAL)"
-	depends on EXPERIMENTAL && !IA64_HP_SIM && (!SMP || HOTPLUG_CPU)
+	depends on EXPERIMENTAL && !IA64_HP_SIM && (!SMP || HOTPLUG_CPU) && !XEN_UNPRIVILEGED_GUEST
 	help
 	  kexec is a system call that implements the ability to shutdown your
 	  current kernel, and to start another kernel.  It is like a reboot
Index: linux-2.6.18-xen.hg/arch/ia64/kernel/relocate_kernel.S
===================================================================
--- linux-2.6.18-xen.hg.orig/arch/ia64/kernel/relocate_kernel.S	2008-02-06 14:38:19.000000000 +0900
+++ linux-2.6.18-xen.hg/arch/ia64/kernel/relocate_kernel.S	2008-02-06 15:23:34.000000000 +0900
@@ -20,7 +20,7 @@
         */
 GLOBAL_ENTRY(relocate_new_kernel)
 	.prologue
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 	alloc r31=ar.pfs,8,0,0,0
 #else
 	alloc r31=ar.pfs,4,0,0,0
@@ -37,7 +37,7 @@ GLOBAL_ENTRY(relocate_new_kernel)
         srlz.i
 }
 	;;
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 	dep r2=0,r2,60,4		//to physical address
 #else
 	dep r2=0,r2,61,3		//to physical address
@@ -65,7 +65,7 @@ GLOBAL_ENTRY(relocate_new_kernel)
 1:
 	//physical mode code begin
 	mov b6=in1
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 	dep r28=0,in2,60,4	//to physical address
 #else
 	dep r28=0,in2,61,3	//to physical address
@@ -73,7 +73,7 @@ GLOBAL_ENTRY(relocate_new_kernel)
 
 	// purge all TC entries
 #define O(member)       IA64_CPUINFO_##member##_OFFSET
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 	mov r2=in4			// load phys addr of cpu_info into r2
 #else
         GET_THIS_PADDR(r2, cpu_info)    // load phys addr of cpu_info into r2
@@ -111,7 +111,7 @@ GLOBAL_ENTRY(relocate_new_kernel)
         srlz.i
         ;;
 	//purge TR entry for kernel text and data
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 	mov r16=in5
 #else
         movl r16=KERNEL_START
@@ -146,7 +146,7 @@ GLOBAL_ENTRY(relocate_new_kernel)
         mov r16=IA64_KR(CURRENT_STACK)
         ;;
         shl r16=r16,IA64_GRANULE_SHIFT
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 	mov r19=in6
 #else
         movl r19=PAGE_OFFSET
@@ -221,14 +221,14 @@ GLOBAL_ENTRY(relocate_new_kernel)
 
 .align  32
 memory_stack:
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 	.fill           4096, 1, 0
 #else
 	.fill           8192, 1, 0
 #endif
 memory_stack_end:
 register_stack:
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 	.fill           4096, 1, 0
 #else
 	.fill           8192, 1, 0
