skip user-mode trap tests in rv32mi/rv64mi-p-csr if no user mode
authorHoward Mao <zhehao.mao@gmail.com>
Fri, 22 Jul 2016 21:20:28 +0000 (14:20 -0700)
committerHoward Mao <zhehao.mao@gmail.com>
Fri, 22 Jul 2016 21:20:35 +0000 (14:20 -0700)
isa/rv64si/csr.S

index 3858daad556f3632d5d5c2f8035f3a5c62dbf79b..68f6fb109abce94c67cfff1c33e3d979b6be0bb5 100644 (file)
@@ -34,6 +34,14 @@ RVTEST_CODE_BEGIN
   TEST_CASE( 8, a0, 0xbad0000, li a0, 0x000beef; csrrs a0, sscratch, a0);
   TEST_CASE( 9, a0, 0xbadbeef, csrr a0, sscratch);
 
   TEST_CASE( 8, a0, 0xbad0000, li a0, 0x000beef; csrrs a0, sscratch, a0);
   TEST_CASE( 9, a0, 0xbadbeef, csrr a0, sscratch);
 
+#ifdef __MACHINE_MODE
+  # Figure out if 'U' is set in misa
+  csrr a0, misa   # a0 = csr(misa)
+  srli a0, a0, 20 # a0 = a0 >> 20
+  andi a0, a0, 1  # a0 = a0 & 1
+  beqz a0, finish # if no user mode, skip the rest of these checks
+#endif
+
   # Make sure writing the cycle counter causes an exception.
   # Don't run in supervisor, as we don't delegate illegal instruction traps.
 #ifdef __MACHINE_MODE
   # Make sure writing the cycle counter causes an exception.
   # Don't run in supervisor, as we don't delegate illegal instruction traps.
 #ifdef __MACHINE_MODE
@@ -56,6 +64,7 @@ RVTEST_CODE_BEGIN
   TEST_CASE(11, x0, 0, nop)
 #endif
 
   TEST_CASE(11, x0, 0, nop)
 #endif
 
+finish:
   RVTEST_PASS
 
   # We should only fall through to this if scall failed.
   RVTEST_PASS
 
   # We should only fall through to this if scall failed.