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 04/11] ia64: kexec: Repining for EFI RID

To: xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-ia64-devel] [patch 04/11] ia64: kexec: Repining for EFI RID
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Thu, 20 Mar 2008 15:52:52 +0900
Cc: Aron Griffis <aron@xxxxxx>, Isaku Yamahata <yamahata@xxxxxxxxxxxxx>, Alex Williamson <alex.williamson@xxxxxx>
Delivery-date: Thu, 20 Mar 2008 00:13:22 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20080320065248.456511629@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: quilt/0.46-1
A cut down version of set_one_rr (and ia64_new_rr7) for
use when switching to the EFI RID for SAL, PAL and EFI calls.

It seemeeems to be no need to repin: palcode, mapped_regs or vhpt in this
case. If it turns they do need to be repinned then special care needs to
betaken to track the correct value to repin.  That is generally the values
that were most recently pinned by ia64_new_rr7.

ia64_new_rr7_efi can probably be merged with ia64_new_rr7,
as they are quite similar, but for testing purposes it seems
easier to keep them separate.

Cc: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Cc: Alex Williamson <alex.williamson@xxxxxx>
Cc: Aron Griffis <aron@xxxxxx>
Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>

Index: xen-unstable.hg/xen/arch/ia64/xen/regionreg.c
===================================================================
--- xen-unstable.hg.orig/xen/arch/ia64/xen/regionreg.c  2008-02-06 
15:47:43.000000000 +0900
+++ xen-unstable.hg/xen/arch/ia64/xen/regionreg.c       2008-02-06 
15:47:43.000000000 +0900
@@ -11,6 +11,7 @@
 #include <linux/config.h>
 #include <linux/types.h>
 #include <linux/sched.h>
+#include <linux/percpu.h>
 #include <asm/page.h>
 #include <asm/regionreg.h>
 #include <asm/vhpt.h>
@@ -20,6 +21,7 @@
 
 /* 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_efi(unsigned long rid, unsigned long percpu_pte);
 
 /* RID virtualization mechanism is really simple:  domains have less rid bits
    than the host and the host rid space is shared among the domains.  (Values
@@ -281,6 +283,21 @@ int set_one_rr(unsigned long rr, unsigne
        return 1;
 }
 
+int set_one_rr_efi(unsigned long rr, unsigned long val)
+{
+       unsigned long rreg = REGION_NUMBER(rr);
+
+       BUG_ON(rreg != 6 && rreg != 7);
+
+       if (rreg == 6)
+               set_rr(rr, val);
+       else
+               ia64_new_rr7_efi(val, cpu_isset(smp_processor_id(),
+                                               percpu_set));
+
+       return 1;
+}
+
 void set_virtual_rr0(void)
 {
        struct vcpu *v = current;
Index: xen-unstable.hg/xen/arch/ia64/xen/xenasm.S
===================================================================
--- xen-unstable.hg.orig/xen/arch/ia64/xen/xenasm.S     2008-02-06 
15:22:21.000000000 +0900
+++ xen-unstable.hg/xen/arch/ia64/xen/xenasm.S  2008-02-06 15:47:43.000000000 
+0900
@@ -195,6 +195,144 @@ GLOBAL_ENTRY(ia64_new_rr7)
        br.ret.sptk.many rp
 END(ia64_new_rr7)
 
+
+ /* ia64_new_rr7_efi:
+  *   in0 = rid
+  *   in1 = repin_percpu
+  *
+  * There seems to be no need to repin: palcode, mapped_regs
+  * or vhpt. If they do need to be repinned then special care
+  * needs to betaken to track the correct value to repin.
+  * That is generally the values that were most recently pinned by
+  * ia64_new_rr7.
+  *
+  * This code function could probably be merged with ia64_new_rr7
+  * as it is just a trimmed down version of that function.
+  * However, current can change without repinning occuring,
+  * so simply getting the values from current does not work correctly.
+  */
+
+GLOBAL_ENTRY(ia64_new_rr7_efi)
+       // FIXME? not sure this unwind statement is correct...
+       .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(1)
+       alloc loc1 = ar.pfs, 2, 6, 0, 0
+       movl loc2=PERCPU_ADDR
+1:     {
+         mov loc3 = psr                // save psr
+         mov loc0 = rp                 // save rp
+         mov r8   = ip                 // save ip to compute branch
+       };;
+       .body
+       tpa loc2=loc2                   // grab this BEFORE changing rr7
+       adds r8 = 1f-1b,r8              // calculate return address for call
+       ;;
+       movl r17=PSR_BITS_TO_SET
+       mov loc4=ar.rsc                 // save RSE configuration
+       movl r16=PSR_BITS_TO_CLEAR
+       ;;
+       tpa r8=r8                       // convert rp to physical
+       mov ar.rsc=0                    // put RSE in enforced lazy, LE mode
+       or loc3=loc3,r17                // add in psr the bits to set
+       ;;
+       andcm r16=loc3,r16              // removes bits to clear from psr
+       dep loc5=0,r8,0,KERNEL_TR_PAGE_SHIFT // Xen code paddr
+       br.call.sptk.many rp=ia64_switch_mode_phys
+1:
+       movl    r26=PAGE_KERNEL
+       // now in physical mode with psr.i/ic off so do rr7 switch
+       dep r16=-1,r0,61,3
+       ;;
+       mov     rr[r16]=in0
+       ;;
+       srlz.d
+       ;;
+
+       // re-pin mappings for kernel text and data
+       mov r24=KERNEL_TR_PAGE_SHIFT<<2
+       movl r17=KERNEL_START
+       ;;
+       ptr.i   r17,r24
+       ;;
+       ptr.d   r17,r24
+       ;;
+       srlz.i
+       ;;
+       srlz.d
+       ;;
+       mov r16=IA64_TR_KERNEL
+       mov cr.itir=r24
+       mov cr.ifa=r17
+       or r18=loc5,r26
+       ;;
+       itr.i itr[r16]=r18
+       ;;
+       itr.d dtr[r16]=r18
+       ;;
+       srlz.i
+       ;;
+       srlz.d
+       ;;
+
+       // re-pin mappings for stack (current)
+
+       // unless overlaps with KERNEL_TR
+       dep r18=0,r13,0,KERNEL_TR_PAGE_SHIFT
+       ;;
+       cmp.eq p7,p0=r17,r18
+(p7)   br.cond.sptk ia64_new_rr7_efi_stack_overlaps
+       mov r25=IA64_GRANULE_SHIFT<<2
+       dep r21=0,r13,60,4              // physical address of "current"
+       ;;
+       ptr.d   r13,r25
+       ;;
+       srlz.d
+       ;;
+       or r23=r21,r26                  // construct PA | page properties
+       mov cr.itir=r25
+       mov cr.ifa=r13                  // VA of next task...
+       mov r21=IA64_TR_CURRENT_STACK
+       ;;
+       itr.d dtr[r21]=r23              // wire in new mapping...
+       ;;
+       srlz.d
+       ;;
+ia64_new_rr7_efi_stack_overlaps:
+
+       //  Per-cpu
+       cmp.eq p7,p0=r0,in1
+(p7)   br.cond.sptk ia64_new_rr7_efi_percpu_not_mapped
+       mov r24=PERCPU_PAGE_SHIFT<<2
+       movl r22=PERCPU_ADDR
+       ;;
+       ptr.d   r22,r24
+       ;;
+       srlz.d
+       ;;
+       or r23=loc2,r26
+       mov cr.itir=r24
+       mov cr.ifa=r22
+       mov r25=IA64_TR_PERCPU_DATA
+       ;;
+       itr.d dtr[r25]=r23              // wire in new mapping...
+       ;;
+       srlz.d
+       ;;
+ia64_new_rr7_efi_percpu_not_mapped:
+
+       // done, switch back to virtual and return
+       mov r16=loc3                    // r16= original psr
+       br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode
+       mov psr.l = loc3                // restore init PSR
+
+       ;;
+       mov ar.pfs = loc1
+       mov rp = loc0
+       ;;
+       mov ar.rsc=loc4                 // restore RSE configuration
+       srlz.d                          // seralize restoration of psr.l
+       br.ret.sptk.many rp
+END(ia64_new_rr7_efi)
+
 #if 0 /* Not used */
 #include "minstate.h"
 
Index: xen-unstable.hg/xen/include/asm-ia64/regionreg.h
===================================================================
--- xen-unstable.hg.orig/xen/include/asm-ia64/regionreg.h       2008-02-06 
15:22:21.000000000 +0900
+++ xen-unstable.hg/xen/include/asm-ia64/regionreg.h    2008-02-06 
15:47:43.000000000 +0900
@@ -37,7 +37,7 @@ typedef union ia64_rr {
 #define RR_RID_MASK     0x00000000ffffff00L
 
 
-int set_one_rr(unsigned long rr, unsigned long val);
+int set_one_rr_efi(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
Index: xen-unstable.hg/xen/arch/ia64/xen/mm_init.c
===================================================================
--- xen-unstable.hg.orig/xen/arch/ia64/xen/mm_init.c    2008-02-06 
15:22:21.000000000 +0900
+++ xen-unstable.hg/xen/arch/ia64/xen/mm_init.c 2008-02-06 15:47:44.000000000 
+0900
@@ -18,12 +18,16 @@ struct ia64_mca_tlb_info ia64_mca_tlb_li
 
 extern void ia64_tlb_init (void);
 
+#ifdef XEN
+cpumask_t percpu_set;
+#endif
+
 void __devinit
 ia64_mmu_init (void *my_cpu_data)
 {
        unsigned long psr, impl_va_bits;
        extern void __devinit tlb_init (void);
-       int cpu;
+       int cpu = smp_processor_id();
 
        /* Pin mapping for percpu area into TLB */
        psr = ia64_clear_ic();
@@ -33,6 +37,9 @@ ia64_mmu_init (void *my_cpu_data)
 
        ia64_set_psr(psr);
        ia64_srlz_i();
+#ifdef XEN
+       cpu_set(cpu, percpu_set);
+#endif
 
        /*
         * Check if the virtually mapped linear page table (VMLPT) overlaps 
with a mapped
@@ -72,8 +79,6 @@ ia64_mmu_init (void *my_cpu_data)
        ia64_srlz_d();
 #endif
 
-       cpu = smp_processor_id();
-
        /* mca handler uses cr.lid as key to pick the right entry */
        ia64_mca_tlb_list[cpu].cr_lid = ia64_getreg(_IA64_REG_CR_LID);
 
Index: xen-unstable.hg/xen/include/linux/cpumask.h
===================================================================
--- xen-unstable.hg.orig/xen/include/linux/cpumask.h    2008-02-06 
15:22:21.000000000 +0900
+++ xen-unstable.hg/xen/include/linux/cpumask.h 2008-02-06 15:47:44.000000000 
+0900
@@ -359,6 +359,10 @@ extern cpumask_t cpu_possible_map;
 extern cpumask_t cpu_online_map;
 extern cpumask_t cpu_present_map;
 
+#ifdef XEN
+extern cpumask_t percpu_set;
+#endif
+
 #if NR_CPUS > 1
 #define num_online_cpus()      cpus_weight(cpu_online_map)
 #define num_possible_cpus()    cpus_weight(cpu_possible_map)

-- 

-- 
Horms


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