Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hypervisor support for PrivRw #540

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions debug/gdbserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1649,14 +1649,19 @@ 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}")
Comment on lines +1652 to +1653
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite get it. Which part is responsible for setting misa.H?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the power is turned on, the hart starts executing the brom code. Here does not affect this case, repeated testing will affect CheckMisa.

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_vmodes = self.supported
for privilege in self.supported_vmodes:
self.supported.add(f"{(1 << 2) + privilege}")
else:
self.supported_vmodes = None
self.supported.add(3)

self.disable_pmp()
Expand All @@ -1672,14 +1677,18 @@ 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 = max(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)
if self.supported_vmodes:
# Restore to machine mode
self.gdb.p("$priv=3")

class PrivChange(PrivTest):
"""Test that the core's privilege level actually changes when the debugger
Expand Down
Loading