From 3bdc42b5b82a25ace5622d3321331f0095538a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=95=87?= Date: Fri, 1 Mar 2024 10:43:43 +0800 Subject: [PATCH] [debug] Add hypervisor support for PrivRw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁镇 Change-Id: I635a8f86b407f104ea74f00f4aefa1ce8170cb2d --- debug/gdbserver.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/debug/gdbserver.py b/debug/gdbserver.py index 92f7ce33f..270228bb4 100755 --- a/debug/gdbserver.py +++ b/debug/gdbserver.py @@ -1649,14 +1649,16 @@ def setup(self): # pylint: disable=attribute-defined-outside-init self.gdb.load() - misa = self.hart.misa + # It may be affected by reset halt + misa = self.gdb.p(f"$misa=0x{self.hart.misa:x}") self.supported = set() if misa & (1<<20): self.supported.add(0) if misa & (1<<18): self.supported.add(1) if misa & (1<<7): - self.supported.add(2) + self.supported.add(4) + self.supported.add(5) self.supported.add(3) self.disable_pmp() @@ -1672,14 +1674,17 @@ def setup(self): class PrivRw(PrivTest): """Test reading/writing priv.""" def test(self): - self.write_nop_program(4) - for privilege in range(4): + privilege_limit=len(self.supported)+1 + self.write_nop_program(privilege_limit) + for privilege in range(privilege_limit): self.gdb.p(f"$priv={privilege}") self.gdb.stepi() actual = self.gdb.p("$priv") assertIn(actual, self.supported) if privilege in self.supported: assertEqual(actual, privilege) + # Restore to machine mode + self.gdb.p("$priv=3") class PrivChange(PrivTest): """Test that the core's privilege level actually changes when the debugger