[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [POWERPC][XEN] Clear SLB entries on boot and other cleanups



# HG changeset patch
# User Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
# Node ID 464acece0dad70663f8658ec555db5564ba126c2
# Parent  22e01a4864b0b750922177067860fdcd21e86318
[POWERPC][XEN] Clear SLB entries on boot and other cleanups

This patch clears and SLB entries that might have been left behind by
Firmware and also cleans up the Save and Restore of the segments.

Signed-off-by: Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx>
---
 xen/arch/powerpc/powerpc64/domain.c |   50 +++++++++++++++++++++++++++++-------
 xen/arch/powerpc/powerpc64/ppc970.c |    6 ++--
 xen/include/asm-powerpc/domain.h    |    5 +++
 xen/include/asm-powerpc/processor.h |    2 +
 4 files changed, 52 insertions(+), 11 deletions(-)

diff -r 22e01a4864b0 -r 464acece0dad xen/arch/powerpc/powerpc64/domain.c
--- a/xen/arch/powerpc/powerpc64/domain.c       Thu Sep 07 01:48:42 2006 -0400
+++ b/xen/arch/powerpc/powerpc64/domain.c       Thu Sep 07 02:21:17 2006 -0400
@@ -63,24 +63,31 @@ void load_sprs(struct vcpu *v)
 
 /* XXX evaluate all isyncs in segment code */
 
-static void flush_slb(struct vcpu *v)
+void flush_segments(void)
 {
-    struct slb_entry *slb0 = &v->arch.slb_entries[0];
+    struct slb_entry slb0;
+    ulong zero = 0;
 
-    slbia();
+    __asm__ __volatile__(
+        "slbmfev %0,%2\n"
+        "slbmfee %1,%2\n"
+        :"=&r"(slb0.slb_vsid), "=&r"(slb0.slb_esid)
+        :"r"(zero)
+        :"memory");
 
     /* we manually have to invalidate SLB[0] since slbia doesn't. */
     /* XXX name magic constants! */
-    if (slb0->slb_esid & (1 << (63 - 36))) {
+    if (slb0.slb_esid & SLB_ESID_VALID) {
         ulong rb;
         ulong class;
 
-        class = (slb0->slb_vsid >> (63 - 56)) & 1ULL;
-        rb = slb0->slb_esid & (~0ULL << (63 - 35));
-        rb |= class << (63 - 36);
+        class = !!(slb0.slb_vsid & SLB_ESID_CLASS);
+        rb = slb0.slb_esid & SLB_ESID_MASK;
+        rb |= class << SLBIE_CLASS_LOG;
 
         slbie(rb);
     }
+    slbia();
 }
 
 void save_segments(struct vcpu *v)
@@ -111,7 +118,7 @@ void save_segments(struct vcpu *v)
 #endif
     }
 
-    flush_slb(v);
+    flush_segments();
 }
 
 void load_segments(struct vcpu *v)
@@ -126,7 +133,8 @@ void load_segments(struct vcpu *v)
 
         /* FIXME: should we bother to restore invalid entries */
         /* stuff in the index here */
-        esid |= i & ((0x1UL << (63 - 52 + 1)) - 1);
+        esid &= ~SLBMTE_ENTRY_MASK;
+        esid |= i;
 
         __asm__ __volatile__(
                 "isync\n"
@@ -144,3 +152,27 @@ void load_segments(struct vcpu *v)
 #endif
     }
 }
+
+void dump_segments(int valid)
+{
+    int i;
+
+    printk("Dump %s SLB entries:\n", valid ? "VALID" : "ALL");
+
+    /* save all extra SLBs */
+    for (i = 0; i < NUM_SLB_ENTRIES; i++) {
+        ulong vsid;
+        ulong esid;
+
+        __asm__ __volatile__(
+                "slbmfev %0,%2\n"
+                "slbmfee %1,%2\n"
+                :"=&r"(vsid), "=&r"(esid)
+                :"r"(i)
+                :"memory");
+
+        if (valid && !(esid & SLB_ESID_VALID))
+            continue;
+        printf("S%02d: 0x%016lx 0x%016lx\n", i, vsid, esid);
+    }
+}
diff -r 22e01a4864b0 -r 464acece0dad xen/arch/powerpc/powerpc64/ppc970.c
--- a/xen/arch/powerpc/powerpc64/ppc970.c       Thu Sep 07 01:48:42 2006 -0400
+++ b/xen/arch/powerpc/powerpc64/ppc970.c       Thu Sep 07 02:21:17 2006 -0400
@@ -202,8 +202,10 @@ void cpu_initialize(int cpuid)
 
     mthior(cpu0_hior);
 
-    /* for good luck */
-    __asm__ __volatile__("isync; slbia; isync" : : : "memory");
+#ifdef DEBUG
+    dump_segments(1);
+#endif
+    flush_segments();
 }
 
 void cpu_init_vcpu(struct vcpu *v)
diff -r 22e01a4864b0 -r 464acece0dad xen/include/asm-powerpc/domain.h
--- a/xen/include/asm-powerpc/domain.h  Thu Sep 07 01:48:42 2006 -0400
+++ b/xen/include/asm-powerpc/domain.h  Thu Sep 07 02:21:17 2006 -0400
@@ -52,6 +52,11 @@ struct slb_entry {
     ulong slb_vsid;
     ulong slb_esid;
 };
+#define SLB_ESID_VALID (1ULL << (63 - 36))
+#define SLB_ESID_CLASS (1ULL << (63 - 56))
+#define SLB_ESID_MASK  (~0ULL << (63 - 35))
+#define SLBIE_CLASS_LOG (63-36)
+#define SLBMTE_ENTRY_MASK ((0x1UL << (63 - 52 + 1)) - 1)
 
 struct xencomm;
 
diff -r 22e01a4864b0 -r 464acece0dad xen/include/asm-powerpc/processor.h
--- a/xen/include/asm-powerpc/processor.h       Thu Sep 07 01:48:42 2006 -0400
+++ b/xen/include/asm-powerpc/processor.h       Thu Sep 07 02:21:17 2006 -0400
@@ -50,6 +50,8 @@ extern int cpu_io_mfn(ulong mfn);
 extern int cpu_io_mfn(ulong mfn);
 extern void save_cpu_sprs(struct vcpu *);
 extern void load_cpu_sprs(struct vcpu *);
+extern void flush_segments(void);
+extern void dump_segments(int valid);
 
 /* XXX this could also land us in GDB */
 #define dump_execution_state() BUG()

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.