Unpinning shared_info, mapped_regs and VPD seems to be missing
from ia64_do_tlb_purge and seems to be needed for kexec.

Like VHPT, the pinned value is recored in a percpu variable
so that the correct value can be unpinned.

Cc: Isaku Yamahata <[EMAIL PROTECTED]>
Signed-off-by: Simon Horman <[EMAIL PROTECTED]>

--- 
Tue, 06 May 2008 11:48:25 +1000
* Update for inserted_vhpt-is-always-needed-for-vmx.patch

Wed, 07 May 2008 17:53:30 +1000
* Move declaration of inserted_shared_info up to top of regionreg.c

Thu, 10 Jul 2008 12:02:02 +1000
* Handle VMX context correctly
  - Save mapped_regs in its own per-cpu variable as it is
    not the same as shared_info in a VMX context
  - Unpin VPD

Mon, 14 Jul 2008 16:25:57 +1000
* Updated for vmx_switch_rr7 wrapper patch
* Also unconditionally repin VHPD in ia64_reload_tr

Mon, 14 Jul 2008 21:36:03 +1000
* Purge VPD portion should use ptr.i not ptr.d.
  The purging of the VPD DTLB entry is handled by the purging of mapped_regs
* Cast values saved to _get_cpu_var(inserted_*) to avoid warnings.
  Both changes thanks to Yamahata-san

Index: xen-unstable.hg/xen/arch/ia64/linux-xen/mca_asm.S
===================================================================
--- xen-unstable.hg.orig/xen/arch/ia64/linux-xen/mca_asm.S      2008-07-14 
17:41:29.000000000 +1000
+++ xen-unstable.hg/xen/arch/ia64/linux-xen/mca_asm.S   2008-07-14 
19:16:56.000000000 +1000
@@ -26,6 +26,7 @@
 #include <asm/mca.h>
 #ifdef XEN
 #include <asm/vhpt.h>
+#include <public/arch-ia64.h>
 #endif
 
 /*
@@ -320,7 +321,44 @@ ia64_do_tlb_purge:
        srlz.i
        ;;
 #ifdef XEN
-       // 5. VHPT
+       // 5. shared_info
+       GET_THIS_PADDR(r2, inserted_shared_info);;
+       ld8 r16=[r2]
+       mov r18=XSI_SHIFT<<2
+       ;;
+       ptr.d r16,r18
+       ;;
+       srlz.d
+       ;;
+
+       // 6. mapped_regs
+       GET_THIS_PADDR(r2, inserted_mapped_regs);;
+       ld8 r16=[r2]
+       mov r18=XMAPPEDREGS_SHIFT<<2
+       ;;
+       ptr.d r16,r18
+       ;;
+       srlz.d
+       ;;
+
+       // 7. VPD
+       // The VPD will not be mapped in the case where
+       // a VMX domain hasn't been started since boot
+       GET_THIS_PADDR(r2, inserted_vpd);;
+       ld8 r16=[r2]
+       mov r18=XMAPPEDREGS_SHIFT<<2
+       ;;
+       cmp.eq p7,p0=r2,r0
+       ;;
+(p7)   br.cond.sptk .vpd_not_mapped
+       ;;
+       ptr.i r16,r18
+       ;;
+       srlz.i
+       ;;
+.vpd_not_mapped:
+
+       // 8. VHPT
        // GET_VA_VCPU_VHPT_MADDR() may not give the
        // value of the VHPT currently pinned into the TLB
        GET_THIS_PADDR(r2, inserted_vhpt);;
@@ -485,8 +523,9 @@ ia64_reload_tr:
 #ifdef XEN
 .reload_vhpt:
        // 5. VHPT
-#if VHPT_ENABLED
-       GET_VA_VCPU_VHPT_MADDR(r2,r3);;
+       GET_THIS_PADDR(r1, inserted_vhpt);;
+       cmp.eq p7,p0=r2,r0
+(p7)   br.cond.sptk    .overlap_vhpt   // vhpt isn't mapped.
 
        // avoid overlapping with stack TR
        shr.u r17=r2,IA64_GRANULE_SHIFT
@@ -517,7 +556,6 @@ ia64_reload_tr:
        ;;
 .overlap_vhpt:
 #endif
-#endif
        br.sptk.many done_tlb_purge_and_reload
 err:
        COLD_BOOT_HANDOFF_STATE(r20,r21,r22)
Index: xen-unstable.hg/xen/arch/ia64/xen/regionreg.c
===================================================================
--- xen-unstable.hg.orig/xen/arch/ia64/xen/regionreg.c  2008-07-14 
17:41:29.000000000 +1000
+++ xen-unstable.hg/xen/arch/ia64/xen/regionreg.c       2008-07-14 
19:16:42.000000000 +1000
@@ -49,6 +49,9 @@ static unsigned int domain_rid_bits_defa
 integer_param("dom_rid_bits", domain_rid_bits_default); 
 
 DEFINE_PER_CPU(unsigned long, inserted_vhpt);
+DEFINE_PER_CPU(unsigned long, inserted_shared_info);
+DEFINE_PER_CPU(unsigned long, inserted_mapped_regs);
+DEFINE_PER_CPU(unsigned long, inserted_vpd);
 
 #if 0
 // following already defined in include/asm-ia64/gcc_intrin.h
@@ -266,6 +269,11 @@ int set_one_rr(unsigned long rr, unsigne
 #if VHPT_ENABLED
                __get_cpu_var(inserted_vhpt) = __va_ul(vcpu_vhpt_maddr(v));
 #endif
+               __get_cpu_var(inserted_shared_info) =
+                                       v->domain->arch.shared_info_va;
+               __get_cpu_var(inserted_mapped_regs) =
+                                       v->domain->arch.shared_info_va +
+                                       XMAPPEDREGS_OFS;
                ia64_new_rr7(vmMangleRID(newrrv.rrval),v->domain->shared_info,
                             v->arch.privregs, v->domain->arch.shared_info_va,
                             __va_ul(vcpu_vhpt_maddr(v)));
Index: xen-unstable.hg/xen/include/asm-ia64/regionreg.h
===================================================================
--- xen-unstable.hg.orig/xen/include/asm-ia64/regionreg.h       2008-07-14 
17:41:29.000000000 +1000
+++ xen-unstable.hg/xen/include/asm-ia64/regionreg.h    2008-07-14 
19:16:41.000000000 +1000
@@ -37,6 +37,9 @@ typedef union ia64_rr {
 #define RR_RID_MASK     0x00000000ffffff00L
 
 DECLARE_PER_CPU(unsigned long, inserted_vhpt);
+DECLARE_PER_CPU(unsigned long, inserted_shared_info);
+DECLARE_PER_CPU(unsigned long, inserted_mapped_regs);
+DECLARE_PER_CPU(unsigned long, inserted_vpd);
 
 int set_one_rr(unsigned long rr, unsigned long val);
 
Index: xen-unstable.hg/xen/arch/ia64/vmx/vmx_vcpu.c
===================================================================
--- xen-unstable.hg.orig/xen/arch/ia64/vmx/vmx_vcpu.c   2008-07-14 
17:41:29.000000000 +1000
+++ xen-unstable.hg/xen/arch/ia64/vmx/vmx_vcpu.c        2008-07-14 
17:41:29.000000000 +1000
@@ -200,6 +200,8 @@ void vmx_switch_rr7(unsigned long rid, v
                     void *pal_vaddr, void *shared_arch_info)
 {
     __get_cpu_var(inserted_vhpt) = (unsigned long)guest_vhpt;
+    __get_cpu_var(inserted_vpd) = (unsigned long)shared_arch_info;
+    __get_cpu_var(inserted_mapped_regs) = (unsigned long)shared_arch_info;
     __vmx_switch_rr7(rid, guest_vhpt, pal_vaddr, shared_arch_info);
 }
 

_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@lists.xensource.com
http://lists.xensource.com/xen-ia64-devel

Reply via email to