Subject: Fix xen build.
From: jbeulich@novell.com
Patch-mainline: obsolete

diff -r 5ebccf901d7e drivers/acpi/acpica/hwsleep.c
--- a/drivers/acpi/acpica/hwsleep.c	Wed Sep 02 15:16:15 2009 -0500
+++ b/drivers/acpi/acpica/hwsleep.c	Wed Sep 02 15:17:12 2009 -0500
@@ -416,6 +416,7 @@
  *              THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
  *
  ******************************************************************************/
+#ifndef CONFIG_XEN
 acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)
 {
 	u32 in_value;
@@ -469,6 +470,7 @@
 }
 
 ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios)
+#endif
 
 /*******************************************************************************
  *
diff -r 5ebccf901d7e drivers/base/cpu.c
--- a/drivers/base/cpu.c	Wed Sep 02 15:16:15 2009 -0500
+++ b/drivers/base/cpu.c	Wed Sep 02 15:17:12 2009 -0500
@@ -78,7 +78,7 @@
 }
 #endif /* CONFIG_HOTPLUG_CPU */
 
-#ifdef CONFIG_KEXEC
+#if defined(CONFIG_KEXEC) && !defined(CONFIG_XEN)
 #include <linux/kexec.h>
 
 static ssize_t show_crash_notes(struct sys_device *dev, struct sysdev_attribute *attr,
@@ -217,7 +217,7 @@
 	if (!error)
 		register_cpu_under_node(num, cpu_to_node(num));
 
-#ifdef CONFIG_KEXEC
+#if defined(CONFIG_KEXEC) && !defined(CONFIG_XEN)
 	if (!error)
 		error = sysdev_create_file(&cpu->sysdev, &attr_crash_notes);
 #endif
diff -r 5ebccf901d7e drivers/ide/ide-lib.c
--- a/drivers/ide/ide-lib.c	Wed Sep 02 15:16:15 2009 -0500
+++ b/drivers/ide/ide-lib.c	Wed Sep 02 15:17:12 2009 -0500
@@ -18,6 +18,16 @@
 {
 	u64 addr = BLK_BOUNCE_HIGH;	/* dma64_addr_t */
 
+#ifndef CONFIG_XEN
+	if (!PCI_DMA_BUS_IS_PHYS) {
+		addr = BLK_BOUNCE_ANY;
+	} else if (on && drive->media == ide_disk) {
+		struct device *dev = drive->hwif->dev;
+
+		if (dev && dev->dma_mask)
+			addr = *dev->dma_mask;
+	}
+#else
 	if (on && drive->media == ide_disk) {
 		struct device *dev = drive->hwif->dev;
 
@@ -26,6 +36,7 @@
 		else if (dev && dev->dma_mask)
 			addr = *dev->dma_mask;
 	}
+#endif
 
 	if (drive->queue)
 		blk_queue_bounce_limit(drive->queue, addr);
diff -r 5ebccf901d7e drivers/oprofile/buffer_sync.c
--- a/drivers/oprofile/buffer_sync.c	Wed Sep 02 15:16:15 2009 -0500
+++ b/drivers/oprofile/buffer_sync.c	Wed Sep 02 15:17:12 2009 -0500
@@ -46,7 +46,9 @@
 static DEFINE_SPINLOCK(task_mortuary);
 static void process_task_mortuary(void);
 
+#ifdef CONFIG_XEN
 static int cpu_current_domain[NR_CPUS];
+#endif
 
 /* Take ownership of the task struct and place it on the
  * list for processing. Only after two full buffer syncs
@@ -158,11 +160,13 @@
 int sync_start(void)
 {
 	int err;
+#ifdef CONFIG_XEN
 	int i;
 
 	for (i = 0; i < NR_CPUS; i++) {
 		cpu_current_domain[i] = COORDINATOR_DOMAIN;
 	}
+#endif
 
 	if (!alloc_cpumask_var(&marked_cpus, GFP_KERNEL))
 		return -ENOMEM;
@@ -313,12 +317,14 @@
 	}
 }
 
+#ifdef CONFIG_XEN
 static void add_domain_switch(unsigned long domain_id)
 {
 	add_event_entry(ESCAPE_CODE);
 	add_event_entry(DOMAIN_SWITCH_CODE);
 	add_event_entry(domain_id);
 }
+#endif
 
 static void
 add_user_ctx_switch(struct task_struct const *task, unsigned long cookie)
@@ -541,10 +547,12 @@
 
 	add_cpu_switch(cpu);
 
+#ifdef CONFIG_XEN
 	/* We need to assign the first samples in this CPU buffer to the
 	   same domain that we were processing at the last sync_buffer */
 	if (cpu_current_domain[cpu] != COORDINATOR_DOMAIN)
 		add_domain_switch(cpu_current_domain[cpu]);
+#endif
 
 	op_cpu_buffer_reset(cpu);
 	available = op_cpu_buffer_entries(cpu);
@@ -554,12 +562,14 @@
 		if (!sample)
 			break;
 
+#ifdef CONFIG_XEN
 		if (domain_switch) {
 			cpu_current_domain[cpu] = sample->eip;
 			add_domain_switch(sample->eip);
 			domain_switch = 0;
 			continue;
 		}
+#endif
 
 		if (is_code(sample->eip)) {
 			flags = sample->event;
@@ -585,17 +595,21 @@
 					cookie = get_exec_dcookie(mm);
 				add_user_ctx_switch(new, cookie);
 			}
+#ifdef CONFIG_XEN
 			if (flags & DOMAIN_SWITCH)
 				domain_switch = 1;
+#endif
 			if (op_cpu_buffer_get_size(&entry))
 				add_data(&entry, mm);
 			continue;
 		}
 
+#ifdef CONFIG_XEN
 		if (cpu_current_domain[cpu] != COORDINATOR_DOMAIN) {
 			add_sample_entry(sample->eip, sample->event);
 			continue;
 		}
+#endif
 
 		if (state < sb_bt_start)
 			/* ignore sample */
@@ -612,9 +626,11 @@
 	}
 	release_mm(mm);
 
+#ifdef CONFIG_XEN
 	/* We reset domain to COORDINATOR at each CPU switch */
 	if (cpu_current_domain[cpu] != COORDINATOR_DOMAIN)
 		add_domain_switch(COORDINATOR_DOMAIN);
+#endif
 
 	mark_done(cpu);
 
diff -r 5ebccf901d7e drivers/oprofile/cpu_buffer.c
--- a/drivers/oprofile/cpu_buffer.c	Wed Sep 02 15:16:15 2009 -0500
+++ b/drivers/oprofile/cpu_buffer.c	Wed Sep 02 15:17:12 2009 -0500
@@ -59,7 +59,11 @@
 #define DEFAULT_TIMER_EXPIRE (HZ / 10)
 static int work_enabled;
 
+#ifndef CONFIG_XEN
+#define current_domain COORDINATOR_DOMAIN
+#else
 static int32_t current_domain = COORDINATOR_DOMAIN;
+#endif
 
 unsigned long oprofile_get_cpu_buffer_size(void)
 {
@@ -449,6 +453,7 @@
 	return;
 }
 
+#ifdef CONFIG_XEN
 int oprofile_add_domain_switch(int32_t domain_id)
 {
 	struct oprofile_cpu_buffer * cpu_buf = &cpu_buffer[smp_processor_id()];
@@ -467,6 +472,7 @@
 
 	return 1;
 }
+#endif
 
 /*
  * This serves to avoid cpu buffer overflow, and makes sure
diff -r 5ebccf901d7e drivers/oprofile/oprof.c
--- a/drivers/oprofile/oprof.c	Wed Sep 02 15:16:15 2009 -0500
+++ b/drivers/oprofile/oprof.c	Wed Sep 02 15:17:12 2009 -0500
@@ -37,6 +37,7 @@
  */
 static int timer = 0;
 
+#ifdef CONFIG_XEN
 int oprofile_set_active(int active_domains[], unsigned int adomains)
 {
 	int err;
@@ -62,6 +63,7 @@
 	mutex_unlock(&start_mutex);
 	return err;
 }
+#endif
 
 int oprofile_setup(void)
 {
diff -r 5ebccf901d7e drivers/oprofile/oprofile_files.c
--- a/drivers/oprofile/oprofile_files.c	Wed Sep 02 15:16:15 2009 -0500
+++ b/drivers/oprofile/oprofile_files.c	Wed Sep 02 15:17:12 2009 -0500
@@ -129,6 +129,8 @@
 	.write		= dump_write,
 };
 
+#ifdef CONFIG_XEN
+
 #define TMPBUFSIZE 512
 
 static unsigned int adomains = 0;
@@ -318,6 +320,8 @@
 	.write		= pdomain_write,
 };
 
+#endif /* CONFIG_XEN */
+
 void oprofile_create_files(struct super_block *sb, struct dentry *root)
 {
 	/* reinitialize default values */
@@ -327,8 +331,10 @@
 
 	oprofilefs_create_file(sb, root, "enable", &enable_fops);
 	oprofilefs_create_file_perm(sb, root, "dump", &dump_fops, 0666);
+#ifdef CONFIG_XEN
 	oprofilefs_create_file(sb, root, "active_domains", &active_domain_ops);
 	oprofilefs_create_file(sb, root, "passive_domains", &passive_domain_ops);
+#endif
 	oprofilefs_create_file(sb, root, "buffer", &event_buffer_fops);
 	oprofilefs_create_ulong(sb, root, "buffer_size", &oprofile_buffer_size);
 	oprofilefs_create_ulong(sb, root, "buffer_watershed", &oprofile_buffer_watershed);
diff -r 5ebccf901d7e include/linux/mm.h
--- a/include/linux/mm.h	Wed Sep 02 15:16:15 2009 -0500
+++ b/include/linux/mm.h	Wed Sep 02 15:17:12 2009 -0500
@@ -200,6 +200,7 @@
 	int (*access)(struct vm_area_struct *vma, unsigned long addr,
 		      void *buf, int len, int write);
 
+#ifdef CONFIG_XEN
 	/* Area-specific function for clearing the PTE at @ptep. Returns the
 	 * original value of @ptep. */
 	pte_t (*zap_pte)(struct vm_area_struct *vma,
@@ -207,6 +208,7 @@
 
 	/* called before close() to indicate no more pages should be mapped */
 	void (*unmap)(struct vm_area_struct *area);
+#endif
 
 #ifdef CONFIG_NUMA
 	/*
diff -r 5ebccf901d7e include/linux/oprofile.h
--- a/include/linux/oprofile.h	Wed Sep 02 15:16:15 2009 -0500
+++ b/include/linux/oprofile.h	Wed Sep 02 15:17:12 2009 -0500
@@ -16,8 +16,9 @@
 #include <linux/types.h>
 #include <linux/spinlock.h>
 #include <asm/atomic.h>
-
+#ifdef CONFIG_XEN
 #include <xen/interface/xenoprof.h>
+#endif
  
 /* Each escaped entry is prefixed by ESCAPE_CODE
  * then one of the following codes, then the
@@ -55,11 +56,12 @@
 	/* create any necessary configuration files in the oprofile fs.
 	 * Optional. */
 	int (*create_files)(struct super_block * sb, struct dentry * root);
+#ifdef CONFIG_XEN
 	/* setup active domains with Xen */
 	int (*set_active)(int *active_domains, unsigned int adomains);
 	/* setup passive domains with Xen */
 	int (*set_passive)(int *passive_domains, unsigned int pdomains);
-
+#endif
 	/* Do any necessary interrupt setup. Optional. */
 	int (*setup)(void);
 	/* Do any necessary interrupt shutdown. Optional. */
diff -r 5ebccf901d7e kernel/kexec.c
--- a/kernel/kexec.c	Wed Sep 02 15:16:15 2009 -0500
+++ b/kernel/kexec.c	Wed Sep 02 15:17:12 2009 -0500
@@ -38,8 +38,10 @@
 #include <asm/system.h>
 #include <asm/sections.h>
 
+#ifndef CONFIG_XEN
 /* Per cpu memory for storing cpu states in case of system crash. */
 note_buf_t* crash_notes;
+#endif
 
 /* vmcoreinfo stuff */
 static unsigned char vmcoreinfo_data[VMCOREINFO_BYTES];
@@ -1150,6 +1152,7 @@
 	memcpy(buf, &note, sizeof(note));
 }
 
+#ifndef CONFIG_XEN
 void crash_save_cpu(struct pt_regs *regs, int cpu)
 {
 	struct elf_prstatus prstatus;
@@ -1175,9 +1178,11 @@
 		      	      &prstatus, sizeof(prstatus));
 	final_note(buf);
 }
+#endif
 
 static int __init crash_notes_memory_init(void)
 {
+#ifndef CONFIG_XEN
 	/* Allocate memory for saving cpu registers. */
 	crash_notes = alloc_percpu(note_buf_t);
 	if (!crash_notes) {
@@ -1185,6 +1190,7 @@
 		" states failed\n");
 		return -ENOMEM;
 	}
+#endif
 	return 0;
 }
 module_init(crash_notes_memory_init)
diff -r 5ebccf901d7e mm/memory.c
--- a/mm/memory.c	Wed Sep 02 15:16:15 2009 -0500
+++ b/mm/memory.c	Wed Sep 02 15:17:12 2009 -0500
@@ -812,10 +812,12 @@
 				     page->index > details->last_index))
 					continue;
 			}
+#ifdef CONFIG_XEN
 			if (unlikely(vma->vm_ops && vma->vm_ops->zap_pte))
 				ptent = vma->vm_ops->zap_pte(vma, addr, pte,
 							     tlb->fullmm);
 			else
+#endif
 				ptent = ptep_get_and_clear_full(mm, addr, pte,
 								tlb->fullmm);
 			tlb_remove_tlb_entry(tlb, pte, addr);
diff -r 5ebccf901d7e mm/mmap.c
--- a/mm/mmap.c	Wed Sep 02 15:16:15 2009 -0500
+++ b/mm/mmap.c	Wed Sep 02 15:17:12 2009 -0500
@@ -1787,8 +1787,10 @@
 
 static inline void unmap_vma(struct vm_area_struct *vma)
 {
+#ifdef CONFIG_XEN
 	if (unlikely(vma->vm_ops && vma->vm_ops->unmap))
 		vma->vm_ops->unmap(vma);
+#endif
 }
 
 /*
@@ -2107,8 +2109,10 @@
 
 	arch_exit_mmap(mm);
 
+#ifdef CONFIG_XEN
 	for (vma = mm->mmap; vma; vma = vma->vm_next)
 		unmap_vma(vma);
+#endif
 
 	vma = mm->mmap;
 	if (!vma)	/* Can happen if dup_mmap() received an OOM */
