@@ -1840,6 +1840,9 @@ def test_translation(self):
18401840
18411841 output = self .gdb .c ()
18421842 assertRegex (output , r"\bmain\b" )
1843+
1844+ # User mode
1845+ self .gdb .p ("$priv=0" )
18431846 assertEqual (0xdeadbeef , self .gdb .p ("physical[0]" ))
18441847 assertEqual (0x55667788 , self .gdb .p ("physical[1]" ))
18451848 assertEqual (0xdeadbeef , self .gdb .p ("virtual[0]" ))
@@ -1883,6 +1886,42 @@ def test(self):
18831886 self .gdb .p ("vms=&sv48" )
18841887 self .test_translation ()
18851888
1889+ class HWTranslateTest (TranslateTest ):
1890+ def test_hw_translation (self ):
1891+ output = self .gdb .command ("monitor riscv virt2phys_mode hw" )
1892+ self .gdb .p (output )
1893+ self .test_translation ()
1894+
1895+ class Sv32HWTest (HWTranslateTest ):
1896+ def early_applicable (self ):
1897+ return TranslateTest .early_applicable (self ) and \
1898+ self .hart .progbufsize and self .hart .xlen == 32
1899+
1900+ def test (self ):
1901+ self .check_satp (SATP_MODE_SV32 )
1902+ self .gdb .p ("vms=&sv32" )
1903+ self .test_hw_translation ()
1904+
1905+ class Sv39HWTest (HWTranslateTest ):
1906+ def early_applicable (self ):
1907+ return TranslateTest .early_applicable (self ) and \
1908+ self .hart .progbufsize and self .hart .xlen > 32
1909+
1910+ def test (self ):
1911+ self .check_satp (SATP_MODE_SV39 )
1912+ self .gdb .p ("vms=&sv39" )
1913+ self .test_hw_translation ()
1914+
1915+ class Sv48HWTest (HWTranslateTest ):
1916+ def early_applicable (self ):
1917+ return TranslateTest .early_applicable (self ) and \
1918+ self .hart .progbufsize and self .hart .xlen > 32
1919+
1920+ def test (self ):
1921+ self .check_satp (SATP_MODE_SV48 )
1922+ self .gdb .p ("vms=&sv48" )
1923+ self .test_hw_translation ()
1924+
18861925class VectorTest (GdbSingleHartTest ):
18871926 compile_args = ("programs/vectors.S" , )
18881927
0 commit comments