pass all FP tests if FPU not present
authorAndrew Waterman <waterman@cs.berkeley.edu>
Thu, 2 May 2013 04:02:15 +0000 (21:02 -0700)
committerAndrew Waterman <waterman@cs.berkeley.edu>
Thu, 2 May 2013 04:02:15 +0000 (21:02 -0700)
env/p/riscv_test.h
env/pm/riscv_test.h
env/pt/riscv_test.h
env/v/riscv_test.h
env/v/vm.c

index 35154f0d94d31197a6d0d43b077df381d7ec1565..8ce8490d8c24ec229dfb6e5895334292e036b03a 100644 (file)
@@ -16,9 +16,9 @@
   setpcr cr0, 2;                                                        \
   mfpcr a0, cr0;                                                        \
   and   a0, a0, 2;                                                      \
-  beqz  a0, 1f;                                                         \
-  mtfsr x0;                                                             \
-1:
+  bnez  a0, 2f;                                                         \
+  RVTEST_PASS;                                                          \
+2:mtfsr x0;                                                             \
 
 #define RVTEST_VEC_ENABLE                                               \
   mfpcr a0, cr0;                                                        \
index 357fd3d4990e7727d225c5f8107041f268f2cf7f..fd07ead1d4fe3308a44bac639038d96365aff58b 100644 (file)
@@ -13,9 +13,9 @@
   setpcr cr0, 2;                                                        \
   mfpcr a0, cr0;                                                        \
   and   a0, a0, 2;                                                      \
-  beqz  a0, 1f;                                                         \
-  mtfsr x0;                                                             \
-1:
+  bnez  a0, 2f;                                                         \
+  RVTEST_PASS;                                                          \
+2:mtfsr x0;                                                             \
 
 #define RVTEST_VEC_ENABLE                                               \
   mfpcr a0, cr0;                                                        \
index 52f5f595ad76c076dc9e28550ad1d9e06670b76c..363e6e15ad567c7c9580e91b982c6beea7b3d701 100644 (file)
@@ -13,9 +13,9 @@
   setpcr cr0, 2;                                                        \
   mfpcr a0, cr0;                                                        \
   and   a0, a0, 2;                                                      \
-  beqz  a0, 1f;                                                         \
-  mtfsr x0;                                                             \
-1:
+  bnez  a0, 2f;                                                         \
+  RVTEST_PASS;                                                          \
+2:mtfsr x0;                                                             \
 
 #define RVTEST_VEC_ENABLE                                               \
   mfpcr a0, cr0;                                                        \
index e37ec05b7c1cdaff779dd71fdc1b706ae897c2d2..2a1710d51ad8e341dc809147678047fa50b69b48 100644 (file)
@@ -10,9 +10,6 @@
 #define RVTEST_RV64S                                                    \
 
 #define RVTEST_FP_ENABLE                                                \
-  mfpcr t0, cr0;                                                        \
-  or    t0, t0, 2;                                                      \
-  mtpcr t0, cr0;                                                        \
   mtfsr x0;                                                             \
 
 #define RVTEST_VEC_ENABLE                                               \
@@ -27,6 +24,7 @@
         .align  13;                                                     \
         .global userstart;                                              \
 userstart:                                                              \
+        RVTEST_FP_ENABLE;                                               \
 
 //-----------------------------------------------------------------------
 // End Macro
index 7e1e570b908c41a7f2a9b7be7f47b64b116580e9..422eb8cc8df6fcbcb6f5d235967bb1e250bf1d12 100644 (file)
@@ -22,6 +22,7 @@ static void cputstring(const char* s)
 static void terminate(int code)
 {
   while (mtpcr(PCR_TOHOST, code));
+  while (1);
 }
 
 #define stringify1(x) #x
@@ -30,7 +31,6 @@ static void terminate(int code)
   if (x) break; \
   cputstring("Assertion failed: " stringify(x)); \
   terminate(3); \
-  while(1); \
 } while(0)
 
 #define RELOC(x) ((typeof(x))((char*)(x) + (PGSIZE*MAX_TEST_PAGES)))
@@ -181,13 +181,17 @@ void handle_trap(trapframe_t* tf)
       evict(i*PGSIZE);
 
     terminate(n);
-    while(1);
   }
   else if (tf->cause == CAUSE_FAULT_FETCH)
     handle_fault(tf->epc);
   else if (tf->cause == CAUSE_ILLEGAL_INSTRUCTION)
   {
-    if ((tf->insn & 0xF83FFFFF) == 0x37B)
+    int mtfsr;
+    asm ("la %0, 1f; lw %0, 0(%0); b 2f; 1: mtfsr x0; 2:" : "=r"(mtfsr));
+
+    if (tf->insn == mtfsr)
+      terminate(1); // FP test on non-FP hardware.  "succeed."
+    else if ((tf->insn & 0xF83FFFFF) == 0x37B)
       emulate_vxcptsave(tf);
     else if ((tf->insn & 0xF83FFFFF) == 0x77B)
       emulate_vxcptrestore(tf);
@@ -234,9 +238,6 @@ void vm_boot(long test_addr, long seed)
   mtpcr(PCR_PTBR, l1pt);
   mtpcr(PCR_SR, mfpcr(PCR_SR) | SR_VM | SR_EF);
 
-  if (mfpcr(PCR_SR) & SR_EF)
-    asm volatile ("mtfsr x0");
-
   // relocate
   long adjustment = RELOC(0L), tmp;
   mtpcr(PCR_EVEC, (char*)&trap_entry + adjustment);