WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

[Xen-ia64-devel] [PATCH] EFI mapping: avoid vhpt fault.

To: kuwa@xxxxxxxxxxxxxx, "Simon Horman [Horms]" <simon@xxxxxxxxxxxxx>
Subject: [Xen-ia64-devel] [PATCH] EFI mapping: avoid vhpt fault.
From: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Date: Mon, 28 Jul 2008 17:10:30 +0900
Cc: xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Mon, 28 Jul 2008 01:10:38 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.6i
Kuwamura-san.
At this moment, I'm not sure whether this patch is related to
the PV-on-HVM driver bug you're seeing.
Could you please also try this patch?

[IA64] EFI mapping: avoid vhpt fault.

Before switching to efi mapping, vhpt walker must be disabled.
Otherwise vhpt fault might occur.
After swiching back from efi mapping, vhpt should be pinned down
correctly and vhpt walker should be reenabled.

Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>

diff -r 28ec2544c69c xen/arch/ia64/linux-xen/efi.c
--- a/xen/arch/ia64/linux-xen/efi.c     Mon Jul 28 12:43:05 2008 +0900
+++ b/xen/arch/ia64/linux-xen/efi.c     Mon Jul 28 17:05:49 2008 +0900
@@ -65,14 +65,14 @@
        struct ia64_fpreg fr[6];                                                
                  \
        efi_time_cap_t *atc = NULL;                                             
                  \
        efi_status_t ret;                                                       
                  \
-       XEN_EFI_RR_DECLARE(rr6, rr7);                                           
                  \
+       XEN_EFI_RR_DECLARE(rr6, rr7, pta);                                      
                  \
                                                                                
                  \
        if (tc)                                                                 
                  \
                atc = adjust_arg(tc);                                           
                  \
        ia64_save_scratch_fpregs(fr);                                           
                  \
-       XEN_EFI_RR_ENTER(rr6, rr7);                                             
                  \
+       XEN_EFI_RR_ENTER(rr6, rr7, pta);                                        
                  \
        ret = efi_call_##prefix((efi_get_time_t *) __va(runtime->get_time), 
adjust_arg(tm), atc); \
-       XEN_EFI_RR_LEAVE(rr6, rr7);                                             
                  \
+       XEN_EFI_RR_LEAVE(rr6, rr7, pta);                                        
                  \
        ia64_load_scratch_fpregs(fr);                                           
                  \
        return ret;                                                             
                  \
 }
@@ -83,12 +83,12 @@
 {                                                                              
                \
        struct ia64_fpreg fr[6];                                                
                \
        efi_status_t ret;                                                       
                \
-       XEN_EFI_RR_DECLARE(rr6, rr7);                                           
                  \
+       XEN_EFI_RR_DECLARE(rr6, rr7, pta);                                      
                \
                                                                                
                \
        ia64_save_scratch_fpregs(fr);                                           
                \
-       XEN_EFI_RR_ENTER(rr6, rr7);                                             
                  \
+       XEN_EFI_RR_ENTER(rr6, rr7, pta);                                        
                \
        ret = efi_call_##prefix((efi_set_time_t *) __va(runtime->set_time), 
adjust_arg(tm));    \
-       XEN_EFI_RR_LEAVE(rr6, rr7);                                             
                  \
+       XEN_EFI_RR_LEAVE(rr6, rr7, pta);                                        
                \
        ia64_load_scratch_fpregs(fr);                                           
                \
        return ret;                                                             
                \
 }
@@ -99,13 +99,13 @@
 {                                                                              
                \
        struct ia64_fpreg fr[6];                                                
                \
        efi_status_t ret;                                                       
                \
-       XEN_EFI_RR_DECLARE(rr6, rr7);                                           
                  \
+       XEN_EFI_RR_DECLARE(rr6, rr7, pta);                                      
                \
                                                                                
                \
        ia64_save_scratch_fpregs(fr);                                           
                \
-       XEN_EFI_RR_ENTER(rr6, rr7);                                             
                  \
+       XEN_EFI_RR_ENTER(rr6, rr7, pta);                                        
                \
        ret = efi_call_##prefix((efi_get_wakeup_time_t *) 
__va(runtime->get_wakeup_time),       \
                                adjust_arg(enabled), adjust_arg(pending), 
adjust_arg(tm));      \
-       XEN_EFI_RR_LEAVE(rr6, rr7);                                             
                  \
+       XEN_EFI_RR_LEAVE(rr6, rr7, pta);                                        
                \
        ia64_load_scratch_fpregs(fr);                                           
                \
        return ret;                                                             
                \
 }
@@ -117,15 +117,15 @@
        struct ia64_fpreg fr[6];                                                
                \
        efi_time_t *atm = NULL;                                                 
                \
        efi_status_t ret;                                                       
                \
-       XEN_EFI_RR_DECLARE(rr6, rr7);                                           
                  \
+       XEN_EFI_RR_DECLARE(rr6, rr7, pta);                                      
                \
                                                                                
                \
        if (tm)                                                                 
                \
                atm = adjust_arg(tm);                                           
                \
        ia64_save_scratch_fpregs(fr);                                           
                \
-       XEN_EFI_RR_ENTER(rr6, rr7);                                             
                  \
+       XEN_EFI_RR_ENTER(rr6, rr7, pta);                                        
                \
        ret = efi_call_##prefix((efi_set_wakeup_time_t *) 
__va(runtime->set_wakeup_time),       \
                                enabled, atm);                                  
                \
-       XEN_EFI_RR_LEAVE(rr6, rr7);                                             
                  \
+       XEN_EFI_RR_LEAVE(rr6, rr7, pta);                                        
                \
        ia64_load_scratch_fpregs(fr);                                           
                \
        return ret;                                                             
                \
 }
@@ -138,16 +138,16 @@
        struct ia64_fpreg fr[6];                                                
        \
        u32 *aattr = NULL;                                                      
                \
        efi_status_t ret;                                                       
        \
-       XEN_EFI_RR_DECLARE(rr6, rr7);                                           
                  \
+       XEN_EFI_RR_DECLARE(rr6, rr7, pta);                                      
        \
                                                                                
        \
        if (attr)                                                               
        \
                aattr = adjust_arg(attr);                                       
        \
        ia64_save_scratch_fpregs(fr);                                           
        \
-       XEN_EFI_RR_ENTER(rr6, rr7);                                             
                  \
+       XEN_EFI_RR_ENTER(rr6, rr7, pta);                                        
        \
        ret = efi_call_##prefix((efi_get_variable_t *) 
__va(runtime->get_variable),     \
                                adjust_arg(name), adjust_arg(vendor), aattr,    
        \
                                adjust_arg(data_size), adjust_arg(data));       
        \
-       XEN_EFI_RR_LEAVE(rr6, rr7);                                             
                  \
+       XEN_EFI_RR_LEAVE(rr6, rr7, pta);                                        
        \
        ia64_load_scratch_fpregs(fr);                                           
        \
        return ret;                                                             
        \
 }
@@ -158,13 +158,13 @@
 {                                                                              
                \
        struct ia64_fpreg fr[6];                                                
                \
        efi_status_t ret;                                                       
                \
-       XEN_EFI_RR_DECLARE(rr6, rr7);                                           
                  \
+       XEN_EFI_RR_DECLARE(rr6, rr7, pta);                                      
                \
                                                                                
                \
        ia64_save_scratch_fpregs(fr);                                           
                \
-       XEN_EFI_RR_ENTER(rr6, rr7);                                             
                  \
+       XEN_EFI_RR_ENTER(rr6, rr7, pta);                                        
                \
        ret = efi_call_##prefix((efi_get_next_variable_t *) 
__va(runtime->get_next_variable),   \
                                adjust_arg(name_size), adjust_arg(name), 
adjust_arg(vendor));   \
-       XEN_EFI_RR_LEAVE(rr6, rr7);                                             
                  \
+       XEN_EFI_RR_LEAVE(rr6, rr7, pta);                                        
                \
        ia64_load_scratch_fpregs(fr);                                           
                \
        return ret;                                                             
                \
 }
@@ -176,14 +176,14 @@
 {                                                                              
        \
        struct ia64_fpreg fr[6];                                                
        \
        efi_status_t ret;                                                       
        \
-       XEN_EFI_RR_DECLARE(rr6, rr7);                                           
                  \
+       XEN_EFI_RR_DECLARE(rr6, rr7, pta);                                      
        \
                                                                                
        \
        ia64_save_scratch_fpregs(fr);                                           
        \
-       XEN_EFI_RR_ENTER(rr6, rr7);                                             
                  \
+       XEN_EFI_RR_ENTER(rr6, rr7, pta);                                        
        \
        ret = efi_call_##prefix((efi_set_variable_t *) 
__va(runtime->set_variable),     \
                                adjust_arg(name), adjust_arg(vendor), attr, 
data_size,  \
                                adjust_arg(data));                              
        \
-       XEN_EFI_RR_LEAVE(rr6, rr7);                                             
                  \
+       XEN_EFI_RR_LEAVE(rr6, rr7, pta);                                        
        \
        ia64_load_scratch_fpregs(fr);                                           
        \
        return ret;                                                             
        \
 }
@@ -194,13 +194,13 @@
 {                                                                              
                \
        struct ia64_fpreg fr[6];                                                
                \
        efi_status_t ret;                                                       
                \
-       XEN_EFI_RR_DECLARE(rr6, rr7);                                           
                  \
+       XEN_EFI_RR_DECLARE(rr6, rr7, pta);                                      
                \
                                                                                
                \
        ia64_save_scratch_fpregs(fr);                                           
                \
-       XEN_EFI_RR_ENTER(rr6, rr7);                                             
                  \
+       XEN_EFI_RR_ENTER(rr6, rr7, pta);                                        
                \
        ret = efi_call_##prefix((efi_get_next_high_mono_count_t *)              
                \
                                __va(runtime->get_next_high_mono_count), 
adjust_arg(count));    \
-       XEN_EFI_RR_LEAVE(rr6, rr7);                                             
                  \
+       XEN_EFI_RR_LEAVE(rr6, rr7, pta);                                        
                \
        ia64_load_scratch_fpregs(fr);                                           
                \
        return ret;                                                             
                \
 }
@@ -212,17 +212,17 @@
 {                                                                              
\
        struct ia64_fpreg fr[6];                                                
\
        efi_char16_t *adata = NULL;                                             
\
-       XEN_EFI_RR_DECLARE(rr6, rr7);                                           
                  \
+       XEN_EFI_RR_DECLARE(rr6, rr7, pta);                                      
\
                                                                                
\
        if (data)                                                               
\
                adata = adjust_arg(data);                                       
\
                                                                                
\
        ia64_save_scratch_fpregs(fr);                                           
\
-       XEN_EFI_RR_ENTER(rr6, rr7);                                             
\
+       XEN_EFI_RR_ENTER(rr6, rr7, pta);                                        
\
        efi_call_##prefix((efi_reset_system_t *) __va(runtime->reset_system),   
\
                          reset_type, status, data_size, adata);                
\
        /* should not return, but just in case... */                            
\
-       XEN_EFI_RR_LEAVE(rr6, rr7);                                             
                  \
+       XEN_EFI_RR_LEAVE(rr6, rr7, pta);                                        
\
        ia64_load_scratch_fpregs(fr);                                           
\
 }
 
diff -r 28ec2544c69c xen/arch/ia64/vmx/vmx_phy_mode.c
--- a/xen/arch/ia64/vmx/vmx_phy_mode.c  Mon Jul 28 12:43:05 2008 +0900
+++ b/xen/arch/ia64/vmx/vmx_phy_mode.c  Mon Jul 28 17:05:49 2008 +0900
@@ -169,9 +169,7 @@
        ia64_dv_serialize_data();
        ia64_set_rr((VRN6 << VRN_SHIFT), vrrtomrr(vcpu, VMX(vcpu, vrr[VRN6])));
        ia64_dv_serialize_data();
-       vmx_switch_rr7(vrrtomrr(vcpu,VMX(vcpu, vrr[VRN7])),
-                      (void *)vcpu->arch.vhpt.hash,
-                      vcpu->arch.privregs);
+       vmx_switch_rr7_vcpu(vcpu, vrrtomrr(vcpu, VMX(vcpu, vrr[VRN7])));
        ia64_set_pta(VMX(vcpu, mpta));
        vmx_ia64_set_dcr(vcpu);
 
diff -r 28ec2544c69c xen/arch/ia64/vmx/vmx_vcpu.c
--- a/xen/arch/ia64/vmx/vmx_vcpu.c      Mon Jul 28 12:43:05 2008 +0900
+++ b/xen/arch/ia64/vmx/vmx_vcpu.c      Mon Jul 28 17:05:49 2008 +0900
@@ -196,13 +196,17 @@
     }
 }
 
-void vmx_switch_rr7(unsigned long rid, void *guest_vhpt,
-                    void *shared_arch_info)
+void __vmx_switch_rr7_vcpu(struct vcpu *v, unsigned long rid)
 {
-    __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, shared_arch_info);
+    __vmx_switch_rr7(rid, (void *)v->arch.vhpt.hash, v->arch.privregs);
+}
+
+void vmx_switch_rr7_vcpu(struct vcpu *v, unsigned long rid)
+{
+    __get_cpu_var(inserted_vhpt) = (unsigned long)v->arch.vhpt.hash;
+    __get_cpu_var(inserted_vpd) = (unsigned long)v->arch.privregs;
+    __get_cpu_var(inserted_mapped_regs) = (unsigned long)v->arch.privregs;
+    __vmx_switch_rr7_vcpu(v, rid);
 }
 
 IA64FAULT vmx_vcpu_set_rr(VCPU *vcpu, u64 reg, u64 val)
@@ -218,8 +222,7 @@
     switch((u64)(reg>>VRN_SHIFT)) {
     case VRN7:
         if (likely(vcpu == current))
-            vmx_switch_rr7(vrrtomrr(vcpu,val), (void *)vcpu->arch.vhpt.hash,
-                           vcpu->arch.privregs);
+            vmx_switch_rr7_vcpu(vcpu, vrrtomrr(vcpu, val));
        break;
     case VRN4:
         rrval = vrrtomrr(vcpu,val);
diff -r 28ec2544c69c xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c        Mon Jul 28 12:43:05 2008 +0900
+++ b/xen/arch/ia64/xen/domain.c        Mon Jul 28 17:05:49 2008 +0900
@@ -263,10 +263,8 @@
      * disable VHPT walker.
      * ia64_switch_to() might cause VHPT fault because it flushes
      * dtr[IA64_TR_VHPT] and reinsert the mapping with dtr[IA64_TR_STACK].
-     * (VHPT_SIZE_LOG2 << 2) is just for avoiding
-     * Reserved Register/Field fault.
      */
-    ia64_set_pta(VHPT_SIZE_LOG2 << 2);
+    ia64_disable_vhpt_walker();
     prev = ia64_switch_to(next);
 
     /* Note: ia64_switch_to does not return here at vcpu initialization.  */
diff -r 28ec2544c69c xen/arch/ia64/xen/faults.c
--- a/xen/arch/ia64/xen/faults.c        Mon Jul 28 12:43:05 2008 +0900
+++ b/xen/arch/ia64/xen/faults.c        Mon Jul 28 17:05:49 2008 +0900
@@ -274,7 +274,7 @@
 {
        fp_state_t fp_state;
        fpswa_ret_t ret;
-       XEN_EFI_RR_DECLARE(rr6, rr7);
+       XEN_EFI_RR_DECLARE(rr6, rr7, pta);
 
        if (!fpswa_interface)
                return (fpswa_ret_t) {-1, 0, 0, 0};
@@ -300,10 +300,10 @@
         *      unsigned long    *pifs,
         *      void             *fp_state);
         */
-       XEN_EFI_RR_ENTER(rr6, rr7);
+       XEN_EFI_RR_ENTER(rr6, rr7, pta);
        ret = (*fpswa_interface->fpswa) (fp_fault, bundle,
                                         ipsr, fpsr, isr, pr, ifs, &fp_state);
-       XEN_EFI_RR_LEAVE(rr6, rr7);
+       XEN_EFI_RR_LEAVE(rr6, rr7, pta);
 
        return ret;
 }
diff -r 28ec2544c69c xen/arch/ia64/xen/regionreg.c
--- a/xen/arch/ia64/xen/regionreg.c     Mon Jul 28 12:43:05 2008 +0900
+++ b/xen/arch/ia64/xen/regionreg.c     Mon Jul 28 17:05:49 2008 +0900
@@ -18,9 +18,12 @@
 #include <asm/vcpu.h>
 #include <asm/percpu.h>
 #include <asm/pal.h>
+#include <asm/vmx_vcpu.h>
 
 /* Defined in xemasm.S  */
-extern void ia64_new_rr7(unsigned long rid, void *shared_info, void 
*shared_arch_info, unsigned long shared_info_va, unsigned long va_vhpt);
+extern void ia64_new_rr7(unsigned long rid, void *shared_info,
+                        void *shared_arch_info, unsigned long shared_info_va,
+                        unsigned long va_vhpt);
 extern void ia64_new_rr7_efi(unsigned long rid, unsigned long repin_percpu,
                             unsigned long vpd);
 
@@ -237,6 +240,14 @@
        ia64_srlz_d();
 }
 
+static inline void
+ia64_new_rr7_vcpu(struct vcpu *v, unsigned long rid)
+{
+       ia64_new_rr7(rid, v->domain->shared_info,
+                    v->arch.privregs, v->domain->arch.shared_info_va,
+                    __va_ul(vcpu_vhpt_maddr(v)));
+}
+
 // validates and changes a single region register
 // in the currently executing domain
 // Passing a value of -1 is a (successful) no-op
@@ -278,9 +289,7 @@
                __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)));
+               ia64_new_rr7_vcpu(v, vmMangleRID(newrrv.rrval));
        } else {
                set_rr(rr,newrrv.rrval);
        }
@@ -306,6 +315,30 @@
        }
 
        return 1;
+}
+
+void
+set_one_rr_efi_restore(unsigned long rr, unsigned long val)
+{
+       unsigned long rreg = REGION_NUMBER(rr);
+       
+       BUG_ON(rreg != 6 && rreg != 7);
+
+       if (rreg == 6) {
+               ia64_set_rr(rr, val);
+               ia64_srlz_d();
+       } else {
+               if (unlikely(current == NULL || current->domain == NULL ||
+                            is_idle_vcpu(current))) {
+                       ia64_new_rr7_efi(val, cpu_isset(smp_processor_id(),
+                                                       percpu_set),
+                                        0UL);
+               } else if (VMX_DOMAIN(current)) {
+                       __vmx_switch_rr7_vcpu(current, val);
+               } else {
+                       ia64_new_rr7_vcpu(current, val);
+               }
+       }
 }
 
 void set_virtual_rr0(void)
diff -r 28ec2544c69c xen/include/asm-ia64/linux-xen/asm/pal.h
--- a/xen/include/asm-ia64/linux-xen/asm/pal.h  Mon Jul 28 12:43:05 2008 +0900
+++ b/xen/include/asm-ia64/linux-xen/asm/pal.h  Mon Jul 28 17:05:49 2008 +0900
@@ -794,41 +794,41 @@
 
 #define PAL_CALL(iprv,a0,a1,a2,a3) do {                        \
        struct ia64_fpreg fr[6];                        \
-       XEN_EFI_RR_DECLARE(rr6, rr7);                   \
+       XEN_EFI_RR_DECLARE(rr6, rr7, pta);              \
        ia64_save_scratch_fpregs(fr);                   \
-       XEN_EFI_RR_ENTER(rr6, rr7);                     \
+       XEN_EFI_RR_ENTER(rr6, rr7, pta);                \
        iprv = ia64_pal_call_static(a0, a1, a2, a3);    \
-       XEN_EFI_RR_LEAVE(rr6, rr7);                     \
+       XEN_EFI_RR_LEAVE(rr6, rr7, pta);                \
        ia64_load_scratch_fpregs(fr);                   \
 } while (0)
 
 #define PAL_CALL_STK(iprv,a0,a1,a2,a3) do {            \
        struct ia64_fpreg fr[6];                        \
-       XEN_EFI_RR_DECLARE(rr6, rr7);                   \
+       XEN_EFI_RR_DECLARE(rr6, rr7, pta);              \
        ia64_save_scratch_fpregs(fr);                   \
-       XEN_EFI_RR_ENTER(rr6, rr7);                     \
+       XEN_EFI_RR_ENTER(rr6, rr7, pta);                \
        iprv = ia64_pal_call_stacked(a0, a1, a2, a3);   \
-       XEN_EFI_RR_LEAVE(rr6, rr7);                     \
+       XEN_EFI_RR_LEAVE(rr6, rr7, pta);                \
        ia64_load_scratch_fpregs(fr);                   \
 } while (0)
 
 #define PAL_CALL_PHYS(iprv,a0,a1,a2,a3) do {                   \
        struct ia64_fpreg fr[6];                                \
-       XEN_EFI_RR_DECLARE(rr6, rr7);                           \
+       XEN_EFI_RR_DECLARE(rr6, rr7, pta);                      \
        ia64_save_scratch_fpregs(fr);                           \
-       XEN_EFI_RR_ENTER(rr6, rr7);                             \
+       XEN_EFI_RR_ENTER(rr6, rr7, pta);                        \
        iprv = ia64_pal_call_phys_static(a0, a1, a2, a3);       \
-       XEN_EFI_RR_LEAVE(rr6, rr7);                             \
+       XEN_EFI_RR_LEAVE(rr6, rr7, pta);                        \
        ia64_load_scratch_fpregs(fr);                           \
 } while (0)
 
 #define PAL_CALL_PHYS_STK(iprv,a0,a1,a2,a3) do {               \
        struct ia64_fpreg fr[6];                                \
-       XEN_EFI_RR_DECLARE(rr6, rr7);                           \
+       XEN_EFI_RR_DECLARE(rr6, rr7, pta);                      \
        ia64_save_scratch_fpregs(fr);                           \
-       XEN_EFI_RR_ENTER(rr6, rr7);                             \
+       XEN_EFI_RR_ENTER(rr6, rr7, pta);                        \
        iprv = ia64_pal_call_phys_stacked(a0, a1, a2, a3);      \
-       XEN_EFI_RR_LEAVE(rr6, rr7);                             \
+       XEN_EFI_RR_LEAVE(rr6, rr7, pta);                        \
        ia64_load_scratch_fpregs(fr);                           \
 } while (0)
 
diff -r 28ec2544c69c xen/include/asm-ia64/linux-xen/asm/sal.h
--- a/xen/include/asm-ia64/linux-xen/asm/sal.h  Mon Jul 28 12:43:05 2008 +0900
+++ b/xen/include/asm-ia64/linux-xen/asm/sal.h  Mon Jul 28 17:05:49 2008 +0900
@@ -52,12 +52,12 @@
 # define SAL_CALL(result,args...) do {                         \
        unsigned long __ia64_sc_flags;                          \
        struct ia64_fpreg __ia64_sc_fr[6];                      \
-       XEN_EFI_RR_DECLARE(rr6, rr7);                           \
+       XEN_EFI_RR_DECLARE(rr6, rr7, pta);                      \
        ia64_save_scratch_fpregs(__ia64_sc_fr);                 \
        spin_lock_irqsave(&sal_lock, __ia64_sc_flags);          \
-       XEN_EFI_RR_ENTER(rr6, rr7);                             \
+       XEN_EFI_RR_ENTER(rr6, rr7, pta);                        \
        __SAL_CALL(result, args);                               \
-       XEN_EFI_RR_LEAVE(rr6, rr7);                             \
+       XEN_EFI_RR_LEAVE(rr6, rr7, pta);                        \
        spin_unlock_irqrestore(&sal_lock, __ia64_sc_flags);     \
        ia64_load_scratch_fpregs(__ia64_sc_fr);                 \
 } while (0)
@@ -65,24 +65,24 @@
 # define SAL_CALL_NOLOCK(result,args...) do {          \
        unsigned long __ia64_scn_flags;                 \
        struct ia64_fpreg __ia64_scn_fr[6];             \
-       XEN_EFI_RR_DECLARE(rr6, rr7);                   \
+       XEN_EFI_RR_DECLARE(rr6, rr7, pta);              \
        ia64_save_scratch_fpregs(__ia64_scn_fr);        \
        local_irq_save(__ia64_scn_flags);               \
-       XEN_EFI_RR_ENTER(rr6, rr7);                     \
+       XEN_EFI_RR_ENTER(rr6, rr7, pta);                \
        __SAL_CALL(result, args);                       \
-       XEN_EFI_RR_LEAVE(rr6, rr7);                     \
+       XEN_EFI_RR_LEAVE(rr6, rr7, pta);                \
        local_irq_restore(__ia64_scn_flags);            \
        ia64_load_scratch_fpregs(__ia64_scn_fr);        \
 } while (0)
 
 # define SAL_CALL_REENTRANT(result,args...) do {       \
        struct ia64_fpreg __ia64_scs_fr[6];             \
-       XEN_EFI_RR_DECLARE(rr6, rr7);                   \
+       XEN_EFI_RR_DECLARE(rr6, rr7, pta);              \
        ia64_save_scratch_fpregs(__ia64_scs_fr);        \
        preempt_disable();                              \
-       XEN_EFI_RR_ENTER(rr6, rr7);                     \
+       XEN_EFI_RR_ENTER(rr6, rr7, pta);                \
        __SAL_CALL(result, args);                       \
-       XEN_EFI_RR_LEAVE(rr6, rr7);                     \
+       XEN_EFI_RR_LEAVE(rr6, rr7, pta);                \
        preempt_enable();                               \
        ia64_load_scratch_fpregs(__ia64_scs_fr);        \
 } while (0)
diff -r 28ec2544c69c xen/include/asm-ia64/linux-xen/linux/efi.h
--- a/xen/include/asm-ia64/linux-xen/linux/efi.h        Mon Jul 28 12:43:05 
2008 +0900
+++ b/xen/include/asm-ia64/linux-xen/linux/efi.h        Mon Jul 28 17:05:49 
2008 +0900
@@ -410,6 +410,7 @@
 } __attribute ((packed));
 
 #ifdef XEN
+#include <asm/vhpt.h>
 /*
  * According to xen/arch/ia64/xen/regionreg.c the RID space is broken up
  * into large-blocks. Each block belongs to a domain, except 0th block,
@@ -471,7 +472,9 @@
  * to set_one_rr_efi(). To be safe, repin everything anyway.
  */
 
-#define XEN_EFI_RR_ENTER(rr6, rr7) do {                        \
+#define XEN_EFI_RR_ENTER(rr6, rr7, pta) do {           \
+       pta = ia64_get_pta();                           \
+       ia64_disable_vhpt_walker();                     \
        rr6 = ia64_get_rr(6UL << 61);                   \
        rr7 = ia64_get_rr(7UL << 61);                   \
        set_one_rr_efi(6UL << 61, XEN_EFI_RR);          \
@@ -485,11 +488,12 @@
  * to unpin efi_unmap_pal_code() until the outermost call is finished
  */
 
-#define XEN_EFI_RR_LEAVE(rr6, rr7) do {                        \
+#define XEN_EFI_RR_LEAVE(rr6, rr7, pta) do {           \
        if (rr7 != XEN_EFI_RR) {                        \
                efi_unmap_pal_code();                   \
-               set_one_rr_efi(6UL << 61, rr6);         \
-               set_one_rr_efi(7UL << 61, rr7);         \
+               set_one_rr_efi_restore(6UL << 61, rr6); \
+               set_one_rr_efi_restore(7UL << 61, rr7); \
+               ia64_set_pta(pta);                      \
        }                                               \
 } while (0)
 
@@ -497,11 +501,15 @@
 /* Just use rr6 and rr7 in a dummy fashion here to get
  * rid of compiler warnings - a better solution should
  * be found if this code is ever actually used */
-#define XEN_EFI_RR_ENTER(rr6, rr7)     do { rr6 = 0; rr7 = 0; } while (0)
-#define XEN_EFI_RR_LEAVE(rr6, rr7)     do {} while (0)
+#define XEN_EFI_RR_ENTER(rr6, rr7, pta) do {   \
+               rr6 = 0;                        \
+               rr7 = 0;                        \
+               pta = 0;                        \
+} while (0)
+#define XEN_EFI_RR_LEAVE(rr6, rr7, pta)        do {} while (0)
 #endif /* XEN */
 
-#define XEN_EFI_RR_DECLARE(rr6, rr7)   unsigned long rr6, rr7;
+#define XEN_EFI_RR_DECLARE(rr6, rr7, pat)      unsigned long rr6, rr7, pta;
 
 #endif /* !__ASSEMBLY__ */
 
diff -r 28ec2544c69c xen/include/asm-ia64/regionreg.h
--- a/xen/include/asm-ia64/regionreg.h  Mon Jul 28 12:43:05 2008 +0900
+++ b/xen/include/asm-ia64/regionreg.h  Mon Jul 28 17:05:49 2008 +0900
@@ -45,6 +45,7 @@
 
 int set_one_rr(unsigned long rr, unsigned long val);
 int set_one_rr_efi(unsigned long rr, unsigned long val);
+void set_one_rr_efi_restore(unsigned long rr, unsigned long val);
 
 // This function is purely for performance... apparently scrambling
 //  bits in the region id makes for better hashing, which means better
diff -r 28ec2544c69c xen/include/asm-ia64/vhpt.h
--- a/xen/include/asm-ia64/vhpt.h       Mon Jul 28 12:43:05 2008 +0900
+++ b/xen/include/asm-ia64/vhpt.h       Mon Jul 28 17:05:49 2008 +0900
@@ -102,6 +102,15 @@
     return sz;
 }
 
+static inline void
+ia64_disable_vhpt_walker(void)
+{
+       /*
+        * (VHPT_SIZE_LOG2 << 2) is just for avoiding
+        * Reserved Register/Field fault.
+        */
+       ia64_set_pta(VHPT_SIZE_LOG2 << 2);
+}
 
 #endif /* !__ASSEMBLY */
 #endif
diff -r 28ec2544c69c xen/include/asm-ia64/vmx_vcpu.h
--- a/xen/include/asm-ia64/vmx_vcpu.h   Mon Jul 28 12:43:05 2008 +0900
+++ b/xen/include/asm-ia64/vmx_vcpu.h   Mon Jul 28 17:05:49 2008 +0900
@@ -105,8 +105,8 @@
 extern void vcpu_load_kernel_regs(VCPU * vcpu);
 extern void __vmx_switch_rr7(unsigned long rid, void *guest_vhpt,
                              void *shared_arch_info);
-extern void vmx_switch_rr7(unsigned long rid, void *guest_vhpt,
-                           void *shared_arch_info);
+extern void __vmx_switch_rr7_vcpu(struct vcpu *v, unsigned long rid);
+extern void vmx_switch_rr7_vcpu(struct vcpu *v, unsigned long rid);
 extern void vmx_ia64_set_dcr(VCPU * v);
 extern void inject_guest_interruption(struct vcpu *vcpu, u64 vec);
 extern void vmx_asm_bsw0(void);


-- 
yamahata

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

<Prev in Thread] Current Thread [Next in Thread>