Skip to content

Commit edebd0d

Browse files
fkhaidarilz-bro
authored andcommitted
Add DCSR.MPRVEN testing
Added test cases to check hardware-provided address translation for program buffer memory accesses
1 parent ec8e5a2 commit edebd0d

4 files changed

Lines changed: 50 additions & 6 deletions

File tree

debug/gdbserver.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
18861925
class VectorTest(GdbSingleHartTest):
18871926
compile_args = ("programs/vectors.S", )
18881927

debug/targets.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,18 @@ class Hart:
5656
# Supports the cease instruction, which causes a hart to become unavailable.
5757
support_cease = False
5858

59-
def __init__(self, misa=None, system=None, link_script_path=None):
59+
progbufsize = None
60+
61+
def __init__(self, misa=None, system=None, link_script_path=None,
62+
progbufsize=None):
6063
if misa:
6164
self.misa = misa
6265
if system:
6366
self.system = system
6467
if link_script_path:
6568
self.link_script_path = link_script_path
69+
if progbufsize:
70+
self.progbufsize = progbufsize
6671

6772
def extensionSupported(self, letter):
6873
# target.misa is set by testlib.ExamineTarget

debug/targets/RISC-V/spike32.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class spike32_hart(targets.Hart):
1111
link_script_path = "spike32.lds"
1212

1313
class spike32(targets.Target):
14-
harts = [spike32_hart(misa=0x403411ad)]
14+
harts = [spike32_hart(misa=0x403411ad, progbufsize=2)]
1515
openocd_config_path = "spike-1.cfg"
1616
timeout_sec = 180
1717
implements_custom_test = True
@@ -24,4 +24,4 @@ def create(self):
2424
return testlib.Spike(self, isa="RV32IMAFDCVH", dmi_rti=4,
2525
support_abstract_csr=True, support_haltgroups=False,
2626
# elen must be at least 64 because D is supported.
27-
elen=64)
27+
elen=64, progbufsize=2)

debug/targets/RISC-V/spike64-2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
import testlib
55

66
class spike64_2(targets.Target):
7-
harts = [spike64.spike64_hart(misa=0x8000000000141129),
8-
spike64.spike64_hart(misa=0x8000000000141129)]
7+
harts = [spike64.spike64_hart(misa=0x8000000000141129, progbufsize=2),
8+
spike64.spike64_hart(misa=0x8000000000141129), progbufsize=2]
99
openocd_config_path = "spike-2.cfg"
1010
timeout_sec = 180
1111
implements_custom_test = True
1212
support_memory_sampling = False # Needs SBA
1313
support_unavailable_control = True
1414

1515
def create(self):
16-
return testlib.Spike(self)
16+
return testlib.Spike(self, progbufsize=2)

0 commit comments

Comments
 (0)