MemMMap: raise error for bad load/fetch addresses when emulating mmap
authorJacob Lifshay <programmerjake@gmail.com>
Wed, 6 Dec 2023 09:08:25 +0000 (01:08 -0800)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 22 Dec 2023 19:26:22 +0000 (19:26 +0000)
src/openpower/decoder/isa/mem.py

index 4947e9b17cba14e40176e2e04af8d11f54109232..2b8c52794c927377478618d062b53f789b074392 100644 (file)
@@ -991,6 +991,12 @@ class MemMMap(MemCommon):
     def __access_addr_range_err(self, start_addr, size, needed_flag):
         assert needed_flag != MMapPageFlags.W, \
             "can't write to address 0x%X size 0x%X" % (start_addr, size)
+        if self.emulating_mmap:
+            exc = MemException("access not allowed",
+                               "memory access not allowed: addr=0x%X: %s"
+                               % (start_addr, needed_flag))
+            exc.dar = start_addr
+            raise exc
         return None, 0
 
     def __access_addr_range(self, start_addr, size, needed_flag):