Skip to contentSkip to conversation

sparc32 do_unassigned_access overhaul

Qemu-devel Artyom Tarasenko 2 participants 14 messages Jan 15, 2010 – Jan 23, 2010

lore
Share & tools
lore
#0 lore raw

According to pages 9-31 - 9-34 of "SuperSPARC & MultiCache Controller User's Manual":

1. "A lower priority fault may not overwrite the
MFSR status of a higher priority fault."
2. The MFAR is overwritten according to the policy defined for the MFSR
3. The overwrite bit is asserted if the fault status register (MFSR) has been written more than once by faults of the same class
4. SuperSPARC will never place instruction fault addresses in the MFAR.

Implementation of points 1-3 allows booting Solaris 2.6 and 2.5.1.

---

target-sparc/op_helper.c +26 -12
index 381e6c4..3a56ce9 100644
@@ -3714,6 +3714,7 @@ void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,
                           int is_asi, int size)
 {
     CPUState *saved_env;
+    int fault_type;
 
     /* XXX: hack to restore env in all cases, even if not called from
        generated code */
@@ -3731,18 +3732,27 @@ void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,
                is_exec ? "exec" : is_write ? "write" : "read", size,
                size == 1 ? "" : "s", addr, env->pc);
 #endif
-    if (env->mmuregs[3]) /* Fault status register */
-        env->mmuregs[3] = 1; /* overflow (not read before another fault) */
-    if (is_asi)
-        env->mmuregs[3] |= 1 << 16;
-    if (env->psrs)
-        env->mmuregs[3] |= 1 << 5;
-    if (is_exec)
-        env->mmuregs[3] |= 1 << 6;
-    if (is_write)
-        env->mmuregs[3] |= 1 << 7;
-    env->mmuregs[3] |= (5 << 2) | 2;
-    env->mmuregs[4] = addr; /* Fault address register */
+    /* Don't overwrite translation and access faults */
+    fault_type=(env->mmuregs[3]&0x1c)>>2;
+    if ((fault_type > 4) || (fault_type==0)) {
+        env->mmuregs[3]=0; /* Fault status register */
+        if (is_asi)
+            env->mmuregs[3] |= 1 << 16;
+        if (env->psrs)
+            env->mmuregs[3] |= 1 << 5;
+        if (is_exec)
+            env->mmuregs[3] |= 1 << 6;
+        if (is_write)
+            env->mmuregs[3] |= 1 << 7;
+        env->mmuregs[3] |= (5 << 2) | 2;
+        /* SuperSPARC will never place instruction fault addresses in the FAR */
+        if (!is_exec)
+            env->mmuregs[4] = addr; /* Fault address register */
+    }
+    /* overflow (same type fault was not read before another fault) */
+    if (fault_type==((env->mmuregs[3]&0x1c))>>2)
+        env->mmuregs[3] |= 1;
+
     if ((env->mmuregs[0] & MMU_E) && !(env->mmuregs[0] & MMU_NF)) {
         if (is_exec)
             raise_exception(TT_CODE_ACCESS);
@@ -3750,6 +3760,10 @@ void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,
             raise_exception(TT_DATA_ACCESS);
     }
     env = saved_env;
+    /* flush neverland mappings created during no-fault mode,
+       so the sequential MMU faults report proper fault types */
+    if (env->mmuregs[0] & MMU_NF)
+        tlb_flush(env, 1);
 }
 #else
 void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,
#1 lore raw
Quoted 11 lines · Artyom Tarasenko

According to pages 9-31 - 9-34 of "SuperSPARC & MultiCache Controller User's Manual":

1. "A lower priority fault may not overwrite the
   MFSR status of a higher priority fault."
2. The MFAR is overwritten according to the policy defined for the MFSR
3. The overwrite bit is asserted if the fault status register (MFSR) has been written more than once by faults of the same class
4. SuperSPARC will never place instruction fault addresses in the MFAR.

Implementation of points 1-3 allows booting Solaris 2.6 and 2.5.1.

Nice work! This also passes my tests. However, there are some CODING_STYLE issues.

Quoted 23 lines

---

target-sparc/op_helper.c +1 -0
index 381e6c4..3a56ce9 100644
@@ -3714,6 +3714,7 @@ void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,
                           int is_asi, int size)
  {
     CPUState *saved_env;
+    int fault_type;
 
     /* XXX: hack to restore env in all cases, even if not called from

       generated code */

target-sparc/op_helper.c +0 -4
@@ -3731,18 +3732,27 @@ void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,
                is_exec ? "exec" : is_write ? "write" : "read", size,
                size == 1 ? "" : "s", addr, env->pc);
  #endif
-    if (env->mmuregs[3]) /* Fault status register */
-        env->mmuregs[3] = 1; /* overflow (not read before another fault) */
-    if (is_asi)
-        env->mmuregs[3] |= 1 << 16;

target-sparc/op_helper.c void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, · line 3736

Quoted 10 lines
target-sparc/op_helper.c +2 -8
-    if (env->psrs)
-        env->mmuregs[3] |= 1 << 5;
-    if (is_exec)
-        env->mmuregs[3] |= 1 << 6;
-    if (is_write)
-        env->mmuregs[3] |= 1 << 7;
-    env->mmuregs[3] |= (5 << 2) | 2;
-    env->mmuregs[4] = addr; /* Fault address register */
+    /* Don't overwrite translation and access faults */
+    fault_type=(env->mmuregs[3]&0x1c)>>2;

Must have spaces around '=', '&' and '>>'.

target-sparc/op_helper.c void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, · line 3737

Quoted 1 line
target-sparc/op_helper.c +1 -0
+    if ((fault_type > 4) || (fault_type==0)) {

Must have spaces around '=='.

target-sparc/op_helper.c void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, · line 3738

Quoted 1 line
target-sparc/op_helper.c +1 -0
+        env->mmuregs[3]=0; /* Fault status register */

and '='

target-sparc/op_helper.c void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, · line 3746

Quoted 8 lines
target-sparc/op_helper.c +8 -0
+        if (is_asi)
+            env->mmuregs[3] |= 1 << 16;
+        if (env->psrs)
+            env->mmuregs[3] |= 1 << 5;
+        if (is_exec)
+            env->mmuregs[3] |= 1 << 6;
+        if (is_write)
+            env->mmuregs[3] |= 1 << 7;

Here you could add the {} which the original lacked, but as this is only code movement it's not needed.

target-sparc/op_helper.c void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, · line 3750

Quoted 4 lines
target-sparc/op_helper.c +4 -0
+        env->mmuregs[3] |= (5 << 2) | 2;
+        /* SuperSPARC will never place instruction fault addresses in the FAR */
+        if (!is_exec)
+            env->mmuregs[4] = addr; /* Fault address register */

But this is new code so {} must be added.

target-sparc/op_helper.c void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, · line 3753

Quoted 3 lines
target-sparc/op_helper.c +3 -0
+    }
+    /* overflow (same type fault was not read before another fault) */
+    if (fault_type==((env->mmuregs[3]&0x1c))>>2)

Must have spaces around '=', '&' and '>>'.

target-sparc/op_helper.c void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, · line 3766

Quoted 13 lines
target-sparc/op_helper.c +6 -0
+        env->mmuregs[3] |= 1;
+
     if ((env->mmuregs[0] & MMU_E) && !(env->mmuregs[0] & MMU_NF)) {
         if (is_exec)
             raise_exception(TT_CODE_ACCESS);
@@ -3750,6 +3760,10 @@ void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,
             raise_exception(TT_DATA_ACCESS);
     }
     env = saved_env;
+    /* flush neverland mappings created during no-fault mode,
+       so the sequential MMU faults report proper fault types */
+    if (env->mmuregs[0] & MMU_NF)
+        tlb_flush(env, 1);

New code, {}.

Quoted 4 lines
target-sparc/op_helper.c +0 -0
  }
  #else
  void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,
#2 lore raw

2010/1/15 Blue Swirl <[email protected]>:

Quoted 12 lines
Quoted 10 lines · Artyom Tarasenko

According to pages 9-31 - 9-34 of "SuperSPARC & MultiCache Controller User's Manual":

1. "A lower priority fault may not overwrite the
   MFSR status of a higher priority fault."
2. The MFAR is overwritten according to the policy defined for the MFSR
3. The overwrite bit is asserted if the fault status register (MFSR) has been written more than once by faults of the same class
4. SuperSPARC will never place instruction fault addresses in the MFAR.

Quoted 3 lines
Quoted 1 line

Implementation of points 1-3 allows booting Solaris 2.6 and 2.5.1.

Nice work! This also passes my tests.

I'm afraid we still are not there yet though: Solaris 7 fails potentially due to another bug in the MMU emulation, and the initial [missing-] RAM detection in OBP fails
very probably due to a bug in in the MMU emulation.

Quoted 1 line

However, there are some CODING_STYLE issues.

Is it something you do by hand (or, actually, by eyes), or is there a way I can automatically test my patches before sending?

Signature · 4 lines
Regards,
Artyom Tarasenko

solaris/sparc under qemu blog: http://tyom.blogspot.com/
#3 lore raw
Quoted 13 lines · Artyom Tarasenko

2010/1/15 Blue Swirl <[email protected]>:

Quoted 12 lines
Quoted 10 lines · Artyom Tarasenko

According to pages 9-31 - 9-34 of "SuperSPARC & MultiCache Controller User's Manual":

1. "A lower priority fault may not overwrite the
   MFSR status of a higher priority fault."
2. The MFAR is overwritten according to the policy defined for the MFSR
3. The overwrite bit is asserted if the fault status register (MFSR) has been written more than once by faults of the same class
4. SuperSPARC will never place instruction fault addresses in the MFAR.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Implementation of points 1-3 allows booting Solaris 2.6 and 2.5.1.

Nice work! This also passes my tests.

I'm afraid we still are not there yet though: Solaris 7 fails potentially due to another bug in the MMU emulation, and the initial [missing-] RAM detection in OBP fails
very probably due to a bug in in the MMU emulation.

Some guesses:
- Access to unassigned RAM area may be handled by the memory
controller differently (no faults, different faults etc.) than unassigned access to SBus or other area.
- Real RAM banks have aliasing effects (which could be emulated by
mapping the aliased RAM areas many times).
- OBP on machines with ECC controller may detect missing RAM using ECC checks.

Quoted 4 lines
Quoted 1 line

However, there are some CODING_STYLE issues.

Is it something you do by hand (or, actually, by eyes), or is there a way I can automatically test my patches before sending?

There is CODING_STYLE document in the QEMU tree, please read it.

It's too bad we don't have a checkpatch script like Linux kernel has. IIRC Anthony once said that he may write one.

#4 lore raw

2010/1/15 Blue Swirl <[email protected]>:

Quoted 24 lines
Quoted 13 lines · Artyom Tarasenko

2010/1/15 Blue Swirl <[email protected]>:

Quoted 12 lines
Quoted 10 lines · Artyom Tarasenko

According to pages 9-31 - 9-34 of "SuperSPARC & MultiCache Controller User's Manual":

1. "A lower priority fault may not overwrite the
   MFSR status of a higher priority fault."
2. The MFAR is overwritten according to the policy defined for the MFSR
3. The overwrite bit is asserted if the fault status register (MFSR) has been written more than once by faults of the same class
4. SuperSPARC will never place instruction fault addresses in the MFAR.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Implementation of points 1-3 allows booting Solaris 2.6 and 2.5.1.

Nice work! This also passes my tests.

I'm afraid we still are not there yet though: Solaris 7 fails potentially due to another bug in the MMU emulation, and the initial [missing-] RAM detection in OBP fails
very probably due to a bug in in the MMU emulation.

Quoted 4 lines

Some guesses:
 - Access to unassigned RAM area may be handled by the memory controller differently (no faults, different faults etc.) than unassigned access to SBus or other area.

It is possible, but may not be the only reason: -M SS-20 -cpu "TI SuperSparc 50" detects missing RAM properly, and -cpu "TI SuperSparc 51" doesn't. Looks like the problem has to do with the cache.

Also Solaris 2.5&2.6 hang with -M SS-20 very early, at the place where they say "vac: enabled in write through mode" on SS-5.

Unfortunately I don't know any cacheless SS-5 cpu, which would have helped to prove the hypothesis.

Quoted 2 lines

 - Real RAM banks have aliasing effects (which could be emulated by mapping the aliased RAM areas many times).

They do, but afaics it should be relevant only for sizes < max RAM bank size.

Quoted 1 line

 - OBP on machines with ECC controller may detect missing RAM using ECC checks.

There is a special message in OBP for ECC failures. (I know it is a weak argument, but still).

Signature · 4 lines
Regards,
Artyom Tarasenko

solaris/sparc under qemu blog: http://tyom.blogspot.com/
#5 lore raw

2010/1/15 Artyom Tarasenko <[email protected]>:

Quoted 29 lines

2010/1/15 Blue Swirl <[email protected]>:

Quoted 28 lines
Quoted 13 lines · Artyom Tarasenko

2010/1/15 Blue Swirl <[email protected]>:

Quoted 12 lines
Quoted 10 lines · Artyom Tarasenko

According to pages 9-31 - 9-34 of "SuperSPARC & MultiCache Controller User's Manual":

1. "A lower priority fault may not overwrite the
   MFSR status of a higher priority fault."
2. The MFAR is overwritten according to the policy defined for the MFSR
3. The overwrite bit is asserted if the fault status register (MFSR) has been written more than once by faults of the same class
4. SuperSPARC will never place instruction fault addresses in the MFAR.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Implementation of points 1-3 allows booting Solaris 2.6 and 2.5.1.

Nice work! This also passes my tests.

I'm afraid we still are not there yet though: Solaris 7 fails potentially due to another bug in the MMU emulation, and the initial [missing-] RAM detection in OBP fails
very probably due to a bug in in the MMU emulation.

Some guesses:
 - Access to unassigned RAM area may be handled by the memory controller differently (no faults, different faults etc.) than unassigned access to SBus or other area.

You are right! It seems to be true for the area larger than max RAM though. On a real SS-5 with 32M in the first bank, no fault is produced at least for the areas
0-0x2fffffff, 0x70000000-0xafffffff (ha, this would solve problems with SS-20 OBP
too) and 0xf0000000-0xf6ffffff.

Would you like to implement it?

That's how I tested it:

ok 8000000 map?
Virtual : 0800.0000
Context : @ 0.01ff.f000 001f.eec1 # 0
Region : @ 0.01fe.ec20 0000.0000 Invalid
ok 8000000 obmem 8000000 map-page
ok 8000000 map?
Virtual : 0800.0000
Context : @ 0.01ff.f000 001f.eec1 # 0
Region : @ 0.01fe.ec20 001f.b231
Segment : @ 0.01fb.2300 001f.b221
Page : @ 0.01fb.2200 0080.001e Access : rwx---
Physical : 0.0800.0000
ok 8000000 20 dump

          \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
 8000000  00 d1 e1 44 ff d1 e2 18  08 d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.
 8000010  00 d1 e1 44 ff d1 e2 18  08 d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.

ok
ok 10000000 map?
Virtual : 1000.0000
Context : @ 0.01ff.f000 001f.eec1 # 0
Region : @ 0.01fe.ec40 0000.0000 Invalid
ok 10000000 obmem 10000000 map-page
ok 10000000 20 dump

          \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
10000000  04 00 00 05 00 1f e0 00  04 00 00 05 00 1f e0 00  ......`.......`.
10000010  04 00 00 05 04 00 00 05  04 00 00 05 04 00 00 05  ................

ok 30000000 map?
Virtual : 3000.0000
Context : @ 0.01ff.f000 001f.eec1 # 0
Region : @ 0.01fe.ecc0 0000.0000 Invalid
ok 30000000 obmem 30000000 map-page
ok 30000000 20 dump

          \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
30000000  Data Access Error
ok 2fff0000 obmem 2fff0000 map-page
ok 2fff0000 20 dump
          \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
2fff0000  02 ff e1 44 ff d1 e2 18  2f d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.
2fff0010  00 d1 e1 44 ff d1 e2 18  2f d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.

ok
ok f0000000 map?
Virtual : f000.0000
Context : @ 0.01ff.f000 001f.eec1 # 0
Region : @ 0.01fe.efc0 0000.0000 Invalid
ok f0000000 obmem f0000000 map-page
ok f0000000 20 dump

          \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
f0000000  10 80 2f 66 a1 48 00 00  01 00 00 00 01 00 00 00  ../f!H..........
f0000010  29 1c 00 04 a8 15 20 d0  81 c5 00 00 a1 48 00 00  )...(. P.E..!H..

ok f7ff0000 map?
Virtual : f7ff.0000
Context : @ 0.01ff.f000 001f.eec1 # 0
Region : @ 0.01fe.efdc 0000.0000 Invalid
ok f7ff0000 obmem f7ff0000 map-page
ok f7ff0000 20 dump

          \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef

f7ff0000 Data Access Error
ok f6ff0000 map?
Virtual : f6ff.0000
Context : @ 0.01ff.f000 001f.eec1 # 0
Region : @ 0.01fe.efd8 0000.0000 Invalid
ok f6ff0000 obmem f6ff0000 map-page
ok f6ff0000 20 dump

          \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef
f6ff0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ................
f6ff0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ................
Signature · 4 lines
Regards,
Artyom Tarasenko

solaris/sparc under qemu blog: http://tyom.blogspot.com/
#6 lore raw
Quoted 31 lines · Artyom Tarasenko

2010/1/15 Artyom Tarasenko <[email protected]>:

Quoted 29 lines

2010/1/15 Blue Swirl <[email protected]>:

Quoted 28 lines
Quoted 13 lines · Artyom Tarasenko

2010/1/15 Blue Swirl <[email protected]>:

Quoted 12 lines
Quoted 10 lines · Artyom Tarasenko

According to pages 9-31 - 9-34 of "SuperSPARC & MultiCache Controller User's Manual":

1. "A lower priority fault may not overwrite the
   MFSR status of a higher priority fault."
2. The MFAR is overwritten according to the policy defined for the MFSR
3. The overwrite bit is asserted if the fault status register (MFSR) has been written more than once by faults of the same class
4. SuperSPARC will never place instruction fault addresses in the MFAR.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Implementation of points 1-3 allows booting Solaris 2.6 and 2.5.1.

Nice work! This also passes my tests.

I'm afraid we still are not there yet though: Solaris 7 fails potentially due to another bug in the MMU emulation, and the initial [missing-] RAM detection in OBP fails
very probably due to a bug in in the MMU emulation.

Some guesses:
 - Access to unassigned RAM area may be handled by the memory controller differently (no faults, different faults etc.) than unassigned access to SBus or other area.

Quoted 6 lines

You are right! It seems to be true for the area larger than max RAM though. On a real SS-5 with 32M in the first bank, no fault is produced at least for the areas
0-0x2fffffff, 0x70000000-0xafffffff (ha, this would solve problems with SS-20 OBP
too) and 0xf0000000-0xf6ffffff.

The fault may still be recorded somewhere else (MXCC, RAM/ECC controller or IOMMU). OBP may have disabled the fault, or it has not enabled fault generation.

On SS-5, the physical address space should be only 31 bits, so you should see RAM aliased at 0x80000000.

Quoted 1 line

Would you like to implement it?

For RAM, there could be a new device which implements generic address space wrapping (base, length, AND mask, OR mask), it should be useful for embedded boards. Shouldn't be too difficult, want to try? :-)

Dummy MMIO could be registered for the other areas in sun4m.c. I'm not sure this is the correct approach, if the fault is still handled somewhere else.

Quoted 18 lines

That's how I tested it:

ok 8000000 map?
Virtual  : 0800.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.ec20  0000.0000 Invalid
ok 8000000 obmem 8000000 map-page
ok 8000000 map?
Virtual  : 0800.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.ec20  001f.b231
Segment  : @ 0.01fb.2300  001f.b221
Page     : @ 0.01fb.2200  0080.001e Access : rwx---
Physical : 0.0800.0000
ok 8000000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef 8000000  00 d1 e1 44 ff d1 e2 18  08 d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb. 8000010  00 d1 e1 44 ff d1 e2 18  08 d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.

RAM?

Quoted 10 lines

ok
ok 10000000 map?
Virtual  : 1000.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.ec40  0000.0000 Invalid
ok 10000000 obmem 10000000 map-page
ok 10000000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef 10000000  04 00 00 05 00 1f e0 00  04 00 00 05 00 1f e0 00  .............. 10000010  04 00 00 05 04 00 00 05  04 00 00 05 04 00 00 05  ................

IOMMU registers here...

Quoted 5 lines

ok 30000000 map?
Virtual  : 3000.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.ecc0  0000.0000 Invalid
ok 30000000 obmem 30000000 map-page

Quoted 8 lines

ok 30000000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef 30000000  Data Access Error
ok 2fff0000 obmem 2fff0000 map-page
ok 2fff0000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef 2fff0000  02 ff e1 44 ff d1 e2 18  2f d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb. 2fff0010  00 d1 e1 44 ff d1 e2 18  2f d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.

RAM again?

Quoted 10 lines

ok
ok f0000000 map?
Virtual  : f000.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.efc0  0000.0000 Invalid
ok f0000000 obmem f0000000 map-page
ok f0000000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef f0000000  10 80 2f 66 a1 48 00 00  01 00 00 00 01 00 00 00  ../f!H.......... f0000010  29 1c 00 04 a8 15 20 d0  81 c5 00 00 a1 48 00 00  )...(. P.E..!H..

This could be boot ROM aliased all over 0xf0000000 to 0xffffffff.

Quoted 24 lines

ok f7ff0000 map?
Virtual  : f7ff.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.efdc  0000.0000 Invalid
ok f7ff0000 obmem f7ff0000 map-page
ok f7ff0000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef f7ff0000  Data Access Error
ok f6ff0000 map?
Virtual  : f6ff.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.efd8  0000.0000 Invalid
ok f6ff0000 obmem f6ff0000 map-page
ok f6ff0000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef f6ff0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ................ f6ff0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ................

--
Regards,
Artyom Tarasenko

solaris/sparc under qemu blog: http://tyom.blogspot.com/

#7 lore raw

2010/1/19 Blue Swirl <[email protected]>:

Quoted 40 lines
Quoted 31 lines · Artyom Tarasenko

2010/1/15 Artyom Tarasenko <[email protected]>:

Quoted 29 lines

2010/1/15 Blue Swirl <[email protected]>:

Quoted 28 lines
Quoted 13 lines · Artyom Tarasenko

2010/1/15 Blue Swirl <[email protected]>:

Quoted 12 lines
Quoted 10 lines · Artyom Tarasenko

According to pages 9-31 - 9-34 of "SuperSPARC & MultiCache Controller User's Manual":

1. "A lower priority fault may not overwrite the
   MFSR status of a higher priority fault."
2. The MFAR is overwritten according to the policy defined for the MFSR
3. The overwrite bit is asserted if the fault status register (MFSR) has been written more than once by faults of the same class
4. SuperSPARC will never place instruction fault addresses in the MFAR.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Implementation of points 1-3 allows booting Solaris 2.6 and 2.5.1.

Nice work! This also passes my tests.

I'm afraid we still are not there yet though: Solaris 7 fails potentially due to another bug in the MMU emulation, and the initial [missing-] RAM detection in OBP fails
very probably due to a bug in in the MMU emulation.

Some guesses:
 - Access to unassigned RAM area may be handled by the memory controller differently (no faults, different faults etc.) than unassigned access to SBus or other area.

Quoted 6 lines

You are right! It seems to be true for the area larger than max RAM though. On a real SS-5 with 32M in the first bank, no fault is produced at least for the areas
0-0x2fffffff, 0x70000000-0xafffffff (ha, this would solve problems with SS-20 OBP
too) and 0xf0000000-0xf6ffffff.

Quoted 2 lines

The fault may still be recorded somewhere else (MXCC, RAM/ECC controller or IOMMU).

sfar and sfsr were empty, so it's definitely not MXCC. Don't know where to look for the other two.

But how the fault would be generated? Don't know about Sun simms, but PC ones don't have any handshake. IMHO the ECC can be the only possibility.

Quoted 2 lines

OBP may have disabled the fault, or it has not
enabled fault generation.

NF bit is not set. Also, you can see the other faults.

Quoted 2 lines

On SS-5, the physical address space should be only 31 bits, so you should see RAM aliased at 0x80000000.

No. The RAM can be aliased only within one bank or completely outside the RAM area. Otherwise different banks would have interfered.

Quoted 5 lines
Quoted 1 line

Would you like to implement it?

For RAM, there could be a new device which implements generic address space wrapping (base, length, AND mask, OR mask), it should be useful for embedded boards. Shouldn't be too difficult, want to try? :-)

Minutes for you, days for me. :)

Quoted 23 lines

Dummy MMIO could be registered for the other areas in sun4m.c. I'm not sure this is the correct approach, if the fault is still handled somewhere else.

Quoted 18 lines

That's how I tested it:

ok 8000000 map?
Virtual  : 0800.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.ec20  0000.0000 Invalid
ok 8000000 obmem 8000000 map-page
ok 8000000 map?
Virtual  : 0800.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.ec20  001f.b231
Segment  : @ 0.01fb.2300  001f.b221
Page     : @ 0.01fb.2200  0080.001e Access : rwx---
Physical : 0.0800.0000
ok 8000000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef 8000000  00 d1 e1 44 ff d1 e2 18  08 d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb. 8000010  00 d1 e1 44 ff d1 e2 18  08 d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.

Quoted 1 line

RAM?

Looks like a white noise to me. The first byte is frequently different. Also the mapped RAM is filled with 0's. The pattern can not be found anywhere in the mapped RAM (0x1000-0x9fffff):

ok create pattern hex 00 c, d1 c, e1 c, 44 c, ff c, d1 c, e2 c, 18 c, ok pattern 8 1000 9effff sindex .
ffffffff
ok

Hold on... I tested only the reading. Should have tested writing too:

ok aa55aa55 8000000 l!
ok sfar@ . sfsr@ .
0 0

no fault, no interrupt, but

ok 8000000 10 dump

          \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef

8000000 00 d1 e1 44 ff d1 e2 18 08 d1 e1 4e ff d1 e2 18 .QaV.Qb..QaV.Qb.
ok

no change either. And if I read it differently I get other contents:
ok 8000000 l@ .
f811bdd

So it's either a noise or a random cache contents.

Quoted 27 lines
Quoted 10 lines

ok
ok 10000000 map?
Virtual  : 1000.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.ec40  0000.0000 Invalid
ok 10000000 obmem 10000000 map-page
ok 10000000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef 10000000  04 00 00 05 00 1f e0 00  04 00 00 05 00 1f e0 00  .............. 10000010  04 00 00 05 04 00 00 05  04 00 00 05 04 00 00 05  ................

IOMMU registers here...

Quoted 5 lines

ok 30000000 map?
Virtual  : 3000.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.ecc0  0000.0000 Invalid
ok 30000000 obmem 30000000 map-page

Quoted 8 lines

ok 30000000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef 30000000  Data Access Error
ok 2fff0000 obmem 2fff0000 map-page
ok 2fff0000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef 2fff0000  02 ff e1 44 ff d1 e2 18  2f d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb. 2fff0010  00 d1 e1 44 ff d1 e2 18  2f d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.

Quoted 1 line

RAM again?

In theory it could be a RAM alias, as it is outside RAM area, but RAM wouldn't be immutable.
And... should have tested this one for writing too:

ok aa55aa55 2fff0000 l!
Level 15 Interrupt
ok sfar@ . sfsr@ .
0 0
ok

No fault, but a NMI! Might be an ECC error as written on page 58 of Sun4m architecture manual. But this particular SS-5 doesn't seem to know anything about ECC. It's not in the device tree and reading the fault address register via asi doesn't work either:

ok 10 2f spacel! .
Data Access Error
ok

Viking CPU also produces NMI after the mmu trap (page 89), but this is a SS-5, so no Vikings. Could be an asynchronous fault, but afar doesn't match:

ok afsr@ . afar@ .
3820000 71100006

So, no idea who pulls the NMI.

Quoted 12 lines
Quoted 11 lines

ok
ok f0000000 map?
Virtual  : f000.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.efc0  0000.0000 Invalid
ok f0000000 obmem f0000000 map-page
ok f0000000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef f0000000  10 80 2f 66 a1 48 00 00  01 00 00 00 01 00 00 00  ../f!H.......... f0000010  29 1c 00 04 a8 15 20 d0  81 c5 00 00 a1 48 00 00  )...(. P.E..!H..

Quoted 1 line

This could be boot ROM aliased all over 0xf0000000 to 0xffffffff.

Yes, probably a ROM alias, but not to 0xffffffff, only to 0xf6ffffff, see the fault below.

Quoted 17 lines
Quoted 17 lines

ok f7ff0000 map?
Virtual  : f7ff.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.efdc  0000.0000 Invalid
ok f7ff0000 obmem f7ff0000 map-page
ok f7ff0000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef f7ff0000  Data Access Error
ok f6ff0000 map?
Virtual  : f6ff.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.efd8  0000.0000 Invalid
ok f6ff0000 obmem f6ff0000 map-page
ok f6ff0000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef f6ff0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ................ f6ff0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ................

Signature · 4 lines
Regards,
Artyom Tarasenko

solaris/sparc under qemu blog: http://tyom.blogspot.com/
#8 lore raw
Quoted 41 lines · Artyom Tarasenko

2010/1/19 Blue Swirl <[email protected]>:

Quoted 40 lines
Quoted 37 lines · Artyom Tarasenko

2010/1/15 Artyom Tarasenko <[email protected]>:

Quoted 29 lines

2010/1/15 Blue Swirl <[email protected]>:

Quoted 28 lines
Quoted 13 lines · Artyom Tarasenko

2010/1/15 Blue Swirl <[email protected]>:

Quoted 12 lines
Quoted 10 lines · Artyom Tarasenko

According to pages 9-31 - 9-34 of "SuperSPARC & MultiCache Controller User's Manual":

1. "A lower priority fault may not overwrite the
   MFSR status of a higher priority fault."
2. The MFAR is overwritten according to the policy defined for the MFSR
3. The overwrite bit is asserted if the fault status register (MFSR) has been written more than once by faults of the same class
4. SuperSPARC will never place instruction fault addresses in the MFAR.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Implementation of points 1-3 allows booting Solaris 2.6 and 2.5.1.

Nice work! This also passes my tests.

I'm afraid we still are not there yet though: Solaris 7 fails potentially due to another bug in the MMU emulation, and the initial [missing-] RAM detection in OBP fails
very probably due to a bug in in the MMU emulation.

Some guesses:
 - Access to unassigned RAM area may be handled by the memory controller differently (no faults, different faults etc.) than unassigned access to SBus or other area.

You are right! It seems to be true for the area larger than max RAM though. On a real SS-5 with 32M in the first bank, no fault is produced at least for the areas
0-0x2fffffff, 0x70000000-0xafffffff (ha, this would solve problems with SS-20 OBP
too) and 0xf0000000-0xf6ffffff.

Quoted 5 lines
Quoted 2 lines

The fault may still be recorded somewhere else (MXCC, RAM/ECC controller or IOMMU).

sfar and sfsr were empty, so it's definitely not MXCC. Don't know where to look for the other two.

For SS-5 there is MFAR and MFSR in IOMMU (0x10001050, 0x10001054), see chapters 6.3.7 and 6.3.8 in "TurboSPARC Microprocessor User's Guide", Fujitsu, October 1996, version 1.0.

SS-20 has M-S AFAR/AFSR (5.2.1 in Sun4m System Architecture Manual) and ECC EFSR and EFAR (5.5.2/5.5.3). With Viking there is also B.III.5.4.6. MXCC Error Register.

Quoted 8 lines

But how the fault would be generated? Don't know about Sun simms, but PC ones don't have any handshake. IMHO the ECC can be the only possibility.

Quoted 2 lines

OBP may have disabled the fault, or it has not
enabled fault generation.

NF bit is not set. Also, you can see the other faults.

I meant memory parity etc. On TurboSparc, parity is enabled in MMU config register. The fault is registerd in MFSR/MFAR.

Quoted 106 lines
Quoted 2 lines

On SS-5, the physical address space should be only 31 bits, so you should see RAM aliased at 0x80000000.

No. The RAM can be aliased only within one bank or completely outside the RAM area. Otherwise different banks would have interfered.

Quoted 5 lines
Quoted 1 line

Would you like to implement it?

For RAM, there could be a new device which implements generic address space wrapping (base, length, AND mask, OR mask), it should be useful for embedded boards. Shouldn't be too difficult, want to try? :-)

Minutes for you, days for me. :)

Quoted 23 lines

Dummy MMIO could be registered for the other areas in sun4m.c. I'm not sure this is the correct approach, if the fault is still handled somewhere else.

Quoted 18 lines

That's how I tested it:

ok 8000000 map?
Virtual  : 0800.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.ec20  0000.0000 Invalid
ok 8000000 obmem 8000000 map-page
ok 8000000 map?
Virtual  : 0800.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.ec20  001f.b231
Segment  : @ 0.01fb.2300  001f.b221
Page     : @ 0.01fb.2200  0080.001e Access : rwx---
Physical : 0.0800.0000
ok 8000000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef 8000000  00 d1 e1 44 ff d1 e2 18  08 d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb. 8000010  00 d1 e1 44 ff d1 e2 18  08 d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.

Quoted 1 line

RAM?

Looks like a white noise to me. The first byte is frequently different. Also the mapped RAM is filled with 0's. The pattern can not be found anywhere in the mapped RAM (0x1000-0x9fffff):

ok create pattern  hex  00 c, d1 c, e1 c, 44 c, ff c, d1 c, e2 c, 18 c, ok pattern 8 1000 9effff sindex .
ffffffff
ok

Hold on... I tested only the reading. Should have tested writing too:

ok aa55aa55 8000000 l!
ok sfar@ . sfsr@ .
0 0

no fault, no interrupt, but

ok 8000000 10 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef 8000000  00 d1 e1 44 ff d1 e2 18  08 d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb. ok

no change either. And if I read it differently I get other contents:
ok 8000000 l@ .
f811bdd

So it's either a noise or a random cache contents.

Quoted 27 lines
Quoted 10 lines

ok
ok 10000000 map?
Virtual  : 1000.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.ec40  0000.0000 Invalid
ok 10000000 obmem 10000000 map-page
ok 10000000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef 10000000  04 00 00 05 00 1f e0 00  04 00 00 05 00 1f e0 00  .............. 10000010  04 00 00 05 04 00 00 05  04 00 00 05 04 00 00 05  ................

IOMMU registers here...

Quoted 5 lines

ok 30000000 map?
Virtual  : 3000.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.ecc0  0000.0000 Invalid
ok 30000000 obmem 30000000 map-page

Quoted 8 lines

ok 30000000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef 30000000  Data Access Error
ok 2fff0000 obmem 2fff0000 map-page
ok 2fff0000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef 2fff0000  02 ff e1 44 ff d1 e2 18  2f d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb. 2fff0010  00 d1 e1 44 ff d1 e2 18  2f d1 e1 4e ff d1 e2 18  .QaV.Qb..QaV.Qb.

Quoted 1 line

RAM again?

In theory it could be a RAM alias, as it is outside RAM area, but RAM wouldn't be immutable.
And... should have tested this one for writing too:

ok aa55aa55 2fff0000 l!
Level 15 Interrupt
ok sfar@ . sfsr@ .
0 0
ok

Quoted 8 lines

No fault, but a NMI! Might be an ECC error as written on page 58 of Sun4m architecture manual. But this particular SS-5 doesn't seem to know anything about ECC. It's not in the device tree and reading the fault address register via asi doesn't work either:

ok 10 2f spacel! .
Data Access Error
ok

No, SS-5 is very different from SS-10/20/600MP so there is no ECC.

Quoted 51 lines

Viking CPU also produces NMI after the mmu trap (page 89), but this is a SS-5, so no Vikings. Could be an asynchronous fault, but afar doesn't match:

ok afsr@ . afar@ .
3820000 71100006

So, no idea who pulls the NMI.

Quoted 12 lines
Quoted 11 lines

ok
ok f0000000 map?
Virtual  : f000.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.efc0  0000.0000 Invalid
ok f0000000 obmem f0000000 map-page
ok f0000000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef f0000000  10 80 2f 66 a1 48 00 00  01 00 00 00 01 00 00 00  ../f!H.......... f0000010  29 1c 00 04 a8 15 20 d0  81 c5 00 00 a1 48 00 00  )...(. P.E..!H..

Quoted 1 line

This could be boot ROM aliased all over 0xf0000000 to 0xffffffff.

Yes, probably a ROM alias, but not to 0xffffffff, only to 0xf6ffffff, see the fault below.

Quoted 9 lines
Quoted 9 lines

ok f7ff0000 map?
Virtual  : f7ff.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.efdc  0000.0000 Invalid
ok f7ff0000 obmem f7ff0000 map-page
ok f7ff0000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef f7ff0000  Data Access Error
ok f6ff0000 map?

Quoted 8 lines
Quoted 8 lines

Virtual  : f6ff.0000
Context  : @ 0.01ff.f000  001f.eec1 # 0
Region   : @ 0.01fe.efd8  0000.0000 Invalid
ok f6ff0000 obmem f6ff0000 map-page
ok f6ff0000 20 dump
         \/  1  2  3  4  5  6  7   8  9  a  b  c  d  e  f  v123456789abcdef f6ff0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ................ f6ff0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ................

--
Regards,
Artyom Tarasenko

solaris/sparc under qemu blog: http://tyom.blogspot.com/

#9 lore raw
In reply to Artyom Tarasenko
Quoted 62 lines · Artyom Tarasenko

2010/1/19 Blue Swirl <[email protected]>:

Quoted 40 lines
Quoted 31 lines · Artyom Tarasenko

2010/1/15 Artyom Tarasenko <[email protected]>:

Quoted 29 lines

2010/1/15 Blue Swirl <[email protected]>:

Quoted 28 lines
Quoted 13 lines · Artyom Tarasenko

2010/1/15 Blue Swirl <[email protected]>:

Quoted 12 lines
Quoted 10 lines · Artyom Tarasenko

According to pages 9-31 - 9-34 of "SuperSPARC & MultiCache Controller User's Manual":

1. "A lower priority fault may not overwrite the
   MFSR status of a higher priority fault."
2. The MFAR is overwritten according to the policy defined for the MFSR
3. The overwrite bit is asserted if the fault status register (MFSR) has been written more than once by faults of the same class
4. SuperSPARC will never place instruction fault addresses in the MFAR.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Implementation of points 1-3 allows booting Solaris 2.6 and 2.5.1.

Nice work! This also passes my tests.

I'm afraid we still are not there yet though: Solaris 7 fails potentially due to another bug in the MMU emulation, and the initial [missing-] RAM detection in OBP fails
very probably due to a bug in in the MMU emulation.

Some guesses:
 - Access to unassigned RAM area may be handled by the memory controller differently (no faults, different faults etc.) than unassigned access to SBus or other area.

Quoted 6 lines

You are right! It seems to be true for the area larger than max RAM though. On a real SS-5 with 32M in the first bank, no fault is produced at least for the areas
0-0x2fffffff, 0x70000000-0xafffffff (ha, this would solve problems with SS-20 OBP
too) and 0xf0000000-0xf6ffffff.

Quoted 2 lines

The fault may still be recorded somewhere else (MXCC, RAM/ECC controller or IOMMU).

sfar and sfsr were empty, so it's definitely not MXCC. Don't know where to look for the other two.

But how the fault would be generated? Don't know about Sun simms, but PC ones don't have any handshake. IMHO the ECC can be the only possibility.

Quoted 2 lines

OBP may have disabled the fault, or it has not
enabled fault generation.

NF bit is not set. Also, you can see the other faults.

Quoted 2 lines

On SS-5, the physical address space should be only 31 bits, so you should see RAM aliased at 0x80000000.

No. The RAM can be aliased only within one bank or completely outside the RAM area. Otherwise different banks would have interfered.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Would you like to implement it?

For RAM, there could be a new device which implements generic address space wrapping (base, length, AND mask, OR mask), it should be useful for embedded boards. Shouldn't be too difficult, want to try? :-)

Minutes for you, days for me. :)

Here's my patch. It implements mapping of bottom 2G to upper 2G. Could you play with the patch and try to implement RAM aliasing so that OBP is content?

From 2a1eabd02b64fd5421e02ed00d0b753c3b9666c0 Mon Sep 17 00:00:00 2001
From: Blue Swirl <[email protected]>
Date: Fri, 22 Jan 2010 17:55:48 +0000
Subject: [PATCH] Add generic address space aliasing mechanism and use it in Sparc32

Some real machines have not connected all CPU bus address lines or the address decoding to chip select lines is performed incompletely. This results in alias effects, where a part of address space can be found in other areas.

Add a generic mechanism to introduce address space aliases and use it in some Sparc32 machines.

---
 cpu-common.h |    3 ++
 exec.c       |   80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/sun4m.c   |   32 +++++++++++++++++++++++
 3 files changed, 115 insertions(+), 0 deletions(-)
cpu-common.h +3 -0
index 6302372..4c94464 100644
@@ -61,6 +61,9 @@ void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len,
 void *cpu_register_map_client(void *opaque, void (*callback)(void *opaque));
 void cpu_unregister_map_client(void *cookie);
 
+void cpu_register_alias(target_phys_addr_t start, ram_addr_t size,
+                        target_phys_addr_t and_mask,
+                        target_phys_addr_t or_mask);
 uint32_t ldub_phys(target_phys_addr_t addr);
 uint32_t lduw_phys(target_phys_addr_t addr);
 uint32_t ldl_phys(target_phys_addr_t addr);
exec.c +80 -0

86 lines not on this page · raw message

hw/sun4m.c +32 -0
index 85fd632..a638478 100644
@@ -98,6 +98,9 @@ struct sun4m_hwdef {
     target_phys_addr_t afx_base, idreg_base, dma_base, esp_base, le_base;
     target_phys_addr_t tcx_base, cs_base, apc_base, aux1_base, aux2_base;
     target_phys_addr_t ecc_base;
+    target_phys_addr_t alias_base;
+    ram_addr_t alias_len;
+    target_phys_addr_t alias_and_mask, alias_or_mask;
     uint32_t ecc_version;
     uint8_t nvram_machine_id;
     uint16_t machine_id;
@@ -904,6 +907,11 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
         ecc_init(hwdef->ecc_base, slavio_irq[28],
                  hwdef->ecc_version);
 
+    if (hwdef->alias_base) {
+        cpu_register_alias(hwdef->alias_base, hwdef->alias_len,
+                           hwdef->alias_and_mask, hwdef->alias_or_mask);
+    }
+
     fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
     fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
     fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
@@ -962,6 +970,10 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {
         .afx_base     = 0x6e000000,
         .aux1_base    = 0x71900000,
         .aux2_base    = 0x71910000,
+        .alias_base   = 0x80000000,
+        .alias_len    = 0x80000000,
+        .alias_and_mask = 0x7fffffff,
+        .alias_or_mask = 0,
         .nvram_machine_id = 0x80,
         .machine_id = ss5_id,
         .iommu_version = 0x05000000,
@@ -1062,6 +1074,10 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {
         .apc_base     = 0x71300000, // pmc
         .aux1_base    = 0x71900000,
         .aux2_base    = 0x71910000,
+        .alias_base   = 0x80000000,
+        .alias_len    = 0x80000000,
+        .alias_and_mask = 0x7fffffff,
+        .alias_or_mask = 0,
         .nvram_machine_id = 0x80,
         .machine_id = vger_id,
         .iommu_version = 0x05000000,
@@ -1085,6 +1101,10 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {
         .le_base      = 0x78c00000,
         .aux1_base    = 0x71900000,
         .aux2_base    = 0x71910000,
+        .alias_base   = 0x80000000,
+        .alias_len    = 0x80000000,
+        .alias_and_mask = 0x7fffffff,
+        .alias_or_mask = 0,
         .nvram_machine_id = 0x80,
         .machine_id = lx_id,
         .iommu_version = 0x04000000,
@@ -1110,6 +1130,10 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {
         .apc_base     = 0x6a000000,
         .aux1_base    = 0x71900000,
         .aux2_base    = 0x71910000,
+        .alias_base   = 0x80000000,
+        .alias_len    = 0x80000000,
+        .alias_and_mask = 0x7fffffff,
+        .alias_or_mask = 0,
         .nvram_machine_id = 0x80,
         .machine_id = ss4_id,
         .iommu_version = 0x05000000,
@@ -1134,6 +1158,10 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {
         .apc_base     = 0x6a000000,
         .aux1_base    = 0x71900000,
         .aux2_base    = 0x71910000,
+        .alias_base   = 0x80000000,
+        .alias_len    = 0x80000000,
+        .alias_and_mask = 0x7fffffff,
+        .alias_or_mask = 0,
         .nvram_machine_id = 0x80,
         .machine_id = scls_id,
         .iommu_version = 0x05000000,
@@ -1158,6 +1186,10 @@ static const struct sun4m_hwdef sun4m_hwdefs[] = {
         .apc_base     = 0x6a000000,
         .aux1_base    = 0x71900000,
         .aux2_base    = 0x71910000,
+        .alias_base   = 0x80000000,
+        .alias_len    = 0x80000000,
+        .alias_and_mask = 0x7fffffff,
+        .alias_or_mask = 0,
         .nvram_machine_id = 0x80,
         .machine_id = sbook_id,
         .iommu_version = 0x05000000,
Signature · 1 line
1.5.6.5
#10 lore raw

2010/1/22 Blue Swirl <[email protected]>:

Quoted 70 lines
Quoted 68 lines · Artyom Tarasenko

2010/1/19 Blue Swirl <[email protected]>:

Quoted 40 lines
Quoted 31 lines · Artyom Tarasenko

2010/1/15 Artyom Tarasenko <[email protected]>:

Quoted 29 lines

2010/1/15 Blue Swirl <[email protected]>:

Quoted 28 lines
Quoted 13 lines · Artyom Tarasenko

2010/1/15 Blue Swirl <[email protected]>:

Quoted 12 lines
Quoted 10 lines · Artyom Tarasenko

According to pages 9-31 - 9-34 of "SuperSPARC & MultiCache Controller User's Manual":

1. "A lower priority fault may not overwrite the
   MFSR status of a higher priority fault."
2. The MFAR is overwritten according to the policy defined for the MFSR
3. The overwrite bit is asserted if the fault status register (MFSR) has been written more than once by faults of the same class
4. SuperSPARC will never place instruction fault addresses in the MFAR.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Implementation of points 1-3 allows booting Solaris 2.6 and 2.5.1.

Nice work! This also passes my tests.

I'm afraid we still are not there yet though: Solaris 7 fails potentially due to another bug in the MMU emulation, and the initial [missing-] RAM detection in OBP fails
very probably due to a bug in in the MMU emulation.

Some guesses:
 - Access to unassigned RAM area may be handled by the memory controller differently (no faults, different faults etc.) than unassigned access to SBus or other area.

Quoted 6 lines

You are right! It seems to be true for the area larger than max RAM though. On a real SS-5 with 32M in the first bank, no fault is produced at least for the areas
0-0x2fffffff, 0x70000000-0xafffffff (ha, this would solve problems with SS-20 OBP
too) and 0xf0000000-0xf6ffffff.

Quoted 2 lines

The fault may still be recorded somewhere else (MXCC, RAM/ECC controller or IOMMU).

sfar and sfsr were empty, so it's definitely not MXCC. Don't know where to look for the other two.

But how the fault would be generated? Don't know about Sun simms, but PC ones don't have any handshake. IMHO the ECC can be the only possibility.

Quoted 2 lines

OBP may have disabled the fault, or it has not
enabled fault generation.

NF bit is not set. Also, you can see the other faults.

Quoted 2 lines

On SS-5, the physical address space should be only 31 bits, so you should see RAM aliased at 0x80000000.

No. The RAM can be aliased only within one bank or completely outside the RAM area. Otherwise different banks would have interfered.

Quoted 5 lines
Quoted 1 line

Would you like to implement it?

For RAM, there could be a new device which implements generic address space wrapping (base, length, AND mask, OR mask), it should be useful for embedded boards. Shouldn't be too difficult, want to try? :-)

Quoted 5 lines
Quoted 1 line

Minutes for you, days for me. :)

Here's my patch. It implements mapping of bottom 2G to upper 2G. Could you play with the patch and try to implement RAM aliasing so that OBP is content?

It's a nice patch, but I'm confused. I thought that in my last mail I proved that we don't observe any RAM aliasing on SS-5. We see some ROM aliasing, but I'm not sure whether it's worth implementing.

Also we see no synchronous faults on SS-5 when accessing missing memory. Haven't tested it on SS-20 yet. I'll try to get an access to a real SS-20 next week (can't have a simultaneous access to the both of them).

Signature · 4 lines
Regards,
Artyom Tarasenko

solaris/sparc under qemu blog: http://tyom.blogspot.com/
#11 lore raw
Quoted 73 lines · Artyom Tarasenko

2010/1/22 Blue Swirl <[email protected]>:

Quoted 72 lines
Quoted 69 lines · Artyom Tarasenko

2010/1/19 Blue Swirl <[email protected]>:

Quoted 40 lines
Quoted 31 lines · Artyom Tarasenko

2010/1/15 Artyom Tarasenko <[email protected]>:

Quoted 29 lines

2010/1/15 Blue Swirl <[email protected]>:

Quoted 28 lines
Quoted 13 lines · Artyom Tarasenko

2010/1/15 Blue Swirl <[email protected]>:

Quoted 12 lines
Quoted 10 lines · Artyom Tarasenko

According to pages 9-31 - 9-34 of "SuperSPARC & MultiCache Controller User's Manual":

1. "A lower priority fault may not overwrite the
   MFSR status of a higher priority fault."
2. The MFAR is overwritten according to the policy defined for the MFSR
3. The overwrite bit is asserted if the fault status register (MFSR) has been written more than once by faults of the same class
4. SuperSPARC will never place instruction fault addresses in the MFAR.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Implementation of points 1-3 allows booting Solaris 2.6 and 2.5.1.

Nice work! This also passes my tests.

I'm afraid we still are not there yet though: Solaris 7 fails potentially due to another bug in the MMU emulation, and the initial [missing-] RAM detection in OBP fails
very probably due to a bug in in the MMU emulation.

Some guesses:
 - Access to unassigned RAM area may be handled by the memory controller differently (no faults, different faults etc.) than unassigned access to SBus or other area.

Quoted 6 lines

You are right! It seems to be true for the area larger than max RAM though. On a real SS-5 with 32M in the first bank, no fault is produced at least for the areas
0-0x2fffffff, 0x70000000-0xafffffff (ha, this would solve problems with SS-20 OBP
too) and 0xf0000000-0xf6ffffff.

Quoted 2 lines

The fault may still be recorded somewhere else (MXCC, RAM/ECC controller or IOMMU).

sfar and sfsr were empty, so it's definitely not MXCC. Don't know where to look for the other two.

But how the fault would be generated? Don't know about Sun simms, but PC ones don't have any handshake. IMHO the ECC can be the only possibility.

Quoted 2 lines

OBP may have disabled the fault, or it has not
enabled fault generation.

NF bit is not set. Also, you can see the other faults.

Quoted 2 lines

On SS-5, the physical address space should be only 31 bits, so you should see RAM aliased at 0x80000000.

No. The RAM can be aliased only within one bank or completely outside the RAM area. Otherwise different banks would have interfered.

Quoted 5 lines
Quoted 1 line

Would you like to implement it?

For RAM, there could be a new device which implements generic address space wrapping (base, length, AND mask, OR mask), it should be useful for embedded boards. Shouldn't be too difficult, want to try? :-)

Minutes for you, days for me. :)

Quoted 7 lines
Quoted 3 lines

Here's my patch. It implements mapping of bottom 2G to upper 2G. Could you play with the patch and try to implement RAM aliasing so that OBP is content?

It's a nice patch, but I'm confused. I thought that in my last mail I proved that we don't observe any RAM aliasing on SS-5. We see some ROM aliasing, but I'm not sure whether it's worth implementing.

I'd still expect some aliasing if a bank has smaller chips than others. For example, if you have 40M of memory and bank size is 16M, there are two full banks and one bank with 8M. This 8M should be aliased within the 16MB area twice.

Otherwise the DRAM controller must somehow know or be told the chip size.

So, the aliasing code could be useful to emulate more arbitrary memory sizes (with OBP), not just multiples of bank sizes.

Quoted 4 lines

Also we see no synchronous faults on SS-5 when accessing missing memory. Haven't tested it on SS-20 yet. I'll try to get an access to a real SS-20 next week (can't have a simultaneous access to the both of them).

Is memory parity enabled?

#12 lore raw

2010/1/23 Blue Swirl <[email protected]>:

Quoted 88 lines
Quoted 73 lines · Artyom Tarasenko

2010/1/22 Blue Swirl <[email protected]>:

Quoted 72 lines
Quoted 69 lines · Artyom Tarasenko

2010/1/19 Blue Swirl <[email protected]>:

Quoted 40 lines
Quoted 31 lines · Artyom Tarasenko

2010/1/15 Artyom Tarasenko <[email protected]>:

Quoted 29 lines

2010/1/15 Blue Swirl <[email protected]>:

Quoted 28 lines
Quoted 13 lines · Artyom Tarasenko

2010/1/15 Blue Swirl <[email protected]>:

Quoted 12 lines
Quoted 10 lines · Artyom Tarasenko

According to pages 9-31 - 9-34 of "SuperSPARC & MultiCache Controller User's Manual":

1. "A lower priority fault may not overwrite the
   MFSR status of a higher priority fault."
2. The MFAR is overwritten according to the policy defined for the MFSR
3. The overwrite bit is asserted if the fault status register (MFSR) has been written more than once by faults of the same class
4. SuperSPARC will never place instruction fault addresses in the MFAR.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Implementation of points 1-3 allows booting Solaris 2.6 and 2.5.1.

Nice work! This also passes my tests.

I'm afraid we still are not there yet though: Solaris 7 fails potentially due to another bug in the MMU emulation, and the initial [missing-] RAM detection in OBP fails
very probably due to a bug in in the MMU emulation.

Some guesses:
 - Access to unassigned RAM area may be handled by the memory controller differently (no faults, different faults etc.) than unassigned access to SBus or other area.

Quoted 6 lines

You are right! It seems to be true for the area larger than max RAM though. On a real SS-5 with 32M in the first bank, no fault is produced at least for the areas
0-0x2fffffff, 0x70000000-0xafffffff (ha, this would solve problems with SS-20 OBP
too) and 0xf0000000-0xf6ffffff.

Quoted 2 lines

The fault may still be recorded somewhere else (MXCC, RAM/ECC controller or IOMMU).

sfar and sfsr were empty, so it's definitely not MXCC. Don't know where to look for the other two.

But how the fault would be generated? Don't know about Sun simms, but PC ones don't have any handshake. IMHO the ECC can be the only possibility.

Quoted 2 lines

OBP may have disabled the fault, or it has not
enabled fault generation.

NF bit is not set. Also, you can see the other faults.

Quoted 2 lines

On SS-5, the physical address space should be only 31 bits, so you should see RAM aliased at 0x80000000.

No. The RAM can be aliased only within one bank or completely outside the RAM area. Otherwise different banks would have interfered.

Quoted 5 lines
Quoted 1 line

Would you like to implement it?

For RAM, there could be a new device which implements generic address space wrapping (base, length, AND mask, OR mask), it should be useful for embedded boards. Shouldn't be too difficult, want to try? :-)

Minutes for you, days for me. :)

Quoted 7 lines
Quoted 3 lines

Here's my patch. It implements mapping of bottom 2G to upper 2G. Could you play with the patch and try to implement RAM aliasing so that OBP is content?

It's a nice patch, but I'm confused. I thought that in my last mail I proved that we don't observe any RAM aliasing on SS-5. We see some ROM aliasing, but I'm not sure whether it's worth implementing.

I'd still expect some aliasing if a bank has smaller chips than others. For example, if you have 40M of memory and bank size is 16M, there are two full banks and one bank with 8M. This 8M should be aliased within the 16MB area twice.

Quoted 4 lines

Otherwise the DRAM controller must somehow know or be told the chip size.

So, the aliasing code could be useful to emulate more arbitrary memory sizes (with OBP), not just multiples of bank sizes.

Yes, but do we need it? Nowadays 32M is small enough (and Classic/X/LX have even smaller memory banks: 16M. Of course if we going to support the Ross Technologies SS-20, it will make sense again, as it has larger memory banks (128M iirc).

But for now wouldn't it be better to focus on fully supporting full banks?

Quoted 6 lines
Quoted 4 lines

Also we see no synchronous faults on SS-5 when accessing missing memory. Haven't tested it on SS-20 yet. I'll try to get an access to a real SS-20 next week (can't have a simultaneous access to the both of them).

Is memory parity enabled?

ok mcr@ .
43d1b01
ok

The 12th bit is set. Are there further parity switches on SS-5?

Signature · 4 lines
Regards,
Artyom Tarasenko

solaris/sparc under qemu blog: http://tyom.blogspot.com/
#13 lore raw
Quoted 94 lines · Artyom Tarasenko

2010/1/23 Blue Swirl <[email protected]>:

Quoted 88 lines
Quoted 73 lines · Artyom Tarasenko

2010/1/22 Blue Swirl <[email protected]>:

Quoted 72 lines
Quoted 69 lines · Artyom Tarasenko

2010/1/19 Blue Swirl <[email protected]>:

Quoted 40 lines
Quoted 31 lines · Artyom Tarasenko

2010/1/15 Artyom Tarasenko <[email protected]>:

Quoted 29 lines

2010/1/15 Blue Swirl <[email protected]>:

Quoted 28 lines
Quoted 13 lines · Artyom Tarasenko

2010/1/15 Blue Swirl <[email protected]>:

Quoted 12 lines
Quoted 10 lines · Artyom Tarasenko

According to pages 9-31 - 9-34 of "SuperSPARC & MultiCache Controller User's Manual":

1. "A lower priority fault may not overwrite the
   MFSR status of a higher priority fault."
2. The MFAR is overwritten according to the policy defined for the MFSR
3. The overwrite bit is asserted if the fault status register (MFSR) has been written more than once by faults of the same class
4. SuperSPARC will never place instruction fault addresses in the MFAR.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Implementation of points 1-3 allows booting Solaris 2.6 and 2.5.1.

Nice work! This also passes my tests.

I'm afraid we still are not there yet though: Solaris 7 fails potentially due to another bug in the MMU emulation, and the initial [missing-] RAM detection in OBP fails
very probably due to a bug in in the MMU emulation.

Some guesses:
 - Access to unassigned RAM area may be handled by the memory controller differently (no faults, different faults etc.) than unassigned access to SBus or other area.

Quoted 6 lines

You are right! It seems to be true for the area larger than max RAM though. On a real SS-5 with 32M in the first bank, no fault is produced at least for the areas
0-0x2fffffff, 0x70000000-0xafffffff (ha, this would solve problems with SS-20 OBP
too) and 0xf0000000-0xf6ffffff.

Quoted 2 lines

The fault may still be recorded somewhere else (MXCC, RAM/ECC controller or IOMMU).

sfar and sfsr were empty, so it's definitely not MXCC. Don't know where to look for the other two.

But how the fault would be generated? Don't know about Sun simms, but PC ones don't have any handshake. IMHO the ECC can be the only possibility.

Quoted 2 lines

OBP may have disabled the fault, or it has not
enabled fault generation.

NF bit is not set. Also, you can see the other faults.

Quoted 2 lines

On SS-5, the physical address space should be only 31 bits, so you should see RAM aliased at 0x80000000.

No. The RAM can be aliased only within one bank or completely outside the RAM area. Otherwise different banks would have interfered.

Quoted 5 lines
Quoted 1 line

Would you like to implement it?

For RAM, there could be a new device which implements generic address space wrapping (base, length, AND mask, OR mask), it should be useful for embedded boards. Shouldn't be too difficult, want to try? :-)

Minutes for you, days for me. :)

Quoted 7 lines
Quoted 3 lines

Here's my patch. It implements mapping of bottom 2G to upper 2G. Could you play with the patch and try to implement RAM aliasing so that OBP is content?

It's a nice patch, but I'm confused. I thought that in my last mail I proved that we don't observe any RAM aliasing on SS-5. We see some ROM aliasing, but I'm not sure whether it's worth implementing.

I'd still expect some aliasing if a bank has smaller chips than others. For example, if you have 40M of memory and bank size is 16M, there are two full banks and one bank with 8M. This 8M should be aliased within the 16MB area twice.

Quoted 4 lines

Otherwise the DRAM controller must somehow know or be told the chip size.

So, the aliasing code could be useful to emulate more arbitrary memory sizes (with OBP), not just multiples of bank sizes.

Quoted 6 lines

Yes, but do we need it? Nowadays 32M is small enough (and Classic/X/LX have even smaller memory banks: 16M. Of course if we going to support the Ross Technologies SS-20, it will make sense again, as it has larger memory banks (128M iirc).

But for now wouldn't it be better to focus on fully supporting full banks?

Right, it's not unreasonable to fix some limits for OBP use case, like 'you must use 256M only'.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Also we see no synchronous faults on SS-5 when accessing missing memory. Haven't tested it on SS-20 yet. I'll try to get an access to a real SS-20 next week (can't have a simultaneous access to the both of them).

Quoted 7 lines
Quoted 1 line

Is memory parity enabled?

ok mcr@ .
43d1b01
ok

The 12th bit is set. Are there further parity switches on SS-5?

Not that I know of.