Subject: [IA64] Kexec: Zap VHPT in relocate_kernel
From: Simon Horman <horms@verge.net.au>
Date: Fri, 13 Jul 2007 16:54:49 +0900

On XEN do_ia64_purge_tlb unpins the VHPT entry, so it seems
logical that relocate_kernel should do the same thing.
It seems to work, but is it correct?

There is a companion hypervisor portion of this patch

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

Index: xen-unstable.hg/xen/arch/ia64/xen/machine_kexec.c
===================================================================
--- xen-unstable.hg.orig/xen/arch/ia64/xen/machine_kexec.c	2007-08-16 17:17:01.000000000 +0900
+++ xen-unstable.hg/xen/arch/ia64/xen/machine_kexec.c	2007-08-16 17:17:07.000000000 +0900
@@ -12,12 +12,14 @@
 #include <xen/lib.h>
 #include <xen/types.h>
 #include <xen/smp.h>
+#include <xen/acpi.h>
 #include <public/kexec.h>
 #include <linux/efi.h>
 #include <asm/delay.h>
 #include <asm/meminit.h>
 #include <asm/hw_irq.h>
 #include <asm/kexec.h>
+#include <asm/vhpt.h>
 #include <linux/cpu.h>
 #include <linux/cpu.h>
 #include <linux/notifier.h>
@@ -29,7 +31,8 @@ typedef asmlinkage NORET_TYPE void (*rel
 					unsigned long pal_addr,
 					unsigned long cpu_data_pa,
 					unsigned long kernel_start,
-					unsigned long page_offset)
+					unsigned long page_offset,
+					unsigned long vhpt)
 					ATTRIB_NORET;
 
 #define kexec_flush_icache_page(page) 					\
@@ -55,6 +58,7 @@ static void ia64_machine_kexec(struct un
     unsigned long cpu_data_pa = (unsigned long)
 				__pa(cpu_data(smp_processor_id()));
     unsigned long vector;
+    unsigned long vhpt;
     int ii;
 
     /* Interrupts aren't acceptable while we reboot */
@@ -82,11 +86,13 @@ static void ia64_machine_kexec(struct un
         vector = ia64_get_ivr();
     }
     platform_kernel_launch_event();
+    vhpt = __va_ul(vcpu_vhpt_maddr(current));
+    BUG_ON(!vhpt);
     rnk = (relocate_new_kernel_t)&code_addr;
     (*rnk)(image->indirection_page, image->start_address,
 	   ia64_boot_param,
            GRANULEROUNDDOWN((unsigned long) pal_vaddr), cpu_data_pa,
-	   KERNEL_START, PAGE_OFFSET);
+	   KERNEL_START, PAGE_OFFSET, vhpt);
     BUG();
 }
 
