From 4407a9c028a6eaa128cd4f37f8f0a35c62890605 Mon Sep 17 00:00:00 2001 From: liangzhen Date: Sun, 4 Feb 2024 16:43:05 +0800 Subject: [PATCH] Add sfence.vma in the disable_pmp function Signed-off-by: liangzhen Change-Id: Ief659c0e68618f5b08a1eee98bc7df92817b8b51 --- debug/targets.py | 4 ++++ debug/testlib.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/debug/targets.py b/debug/targets.py index bb7a5cf15..2c04ed718 100644 --- a/debug/targets.py +++ b/debug/targets.py @@ -141,6 +141,10 @@ class Target: # Instruction count limit icount_limit = 4 + # Implements page-based virtual memory. So when PMP changes execute an + # SFENCE.VMA + implements_page_virtual_memory = True + # Internal variables: directory = None temporary_files = [] diff --git a/debug/testlib.py b/debug/testlib.py index 7f28186cb..a115896cd 100644 --- a/debug/testlib.py +++ b/debug/testlib.py @@ -1453,6 +1453,9 @@ def disable_pmp(self): # pmcfg0 readback matches write, so TOR is supported. self.gdb.p("$pmpaddr0=" f"0x{(self.hart.ram + self.hart.ram_size) >> 2:x}") + if self.target.implements_page_virtual_memory: + # PMP changes require an sfence.vma, 0x12000073 is sfence.vma + self.gdb.command("monitor riscv exec_progbuf 0x12000073") except CouldNotFetch: # PMP registers are optional pass