瀏覽代碼

Don't decode blocks starting outside mapped memory & undefined instead of throw on invalid sysreg coprocessor (#964)

* Don't decode blocks in invalid memory locations.

* Emit undefined instruction on invalid coprocessor

...rather than throwing.

* Call undefined instruction directly.
gdkchan 6 年之前
父節點
當前提交
d9ed827696
共有 2 個文件被更改,包括 7 次插入4 次删除
  1. 1 1
      ARMeilleure/Decoders/Decoder.cs
  2. 6 3
      ARMeilleure/Instructions/InstEmitSystem32.cs

+ 1 - 1
ARMeilleure/Decoders/Decoder.cs

@@ -47,7 +47,7 @@ namespace ARMeilleure.Decoders
             {
                 if (!visited.TryGetValue(blkAddress, out Block block))
                 {
-                    if (opsCount > MaxInstsPerFunction)
+                    if (opsCount > MaxInstsPerFunction || !memory.IsMapped((long)blkAddress))
                     {
                         return null;
                     }

+ 6 - 3
ARMeilleure/Instructions/InstEmitSystem32.cs

@@ -17,7 +17,8 @@ namespace ARMeilleure.Instructions
 
             if (op.Coproc != 15)
             {
-                throw new NotImplementedException($"Unknown MRC Coprocessor ID 0x{op.Coproc:X16} at 0x{op.Address:X16}.");
+                InstEmit.Und(context);
+                return;
             }
 
             if (op.Opc1 != 0)
@@ -70,7 +71,8 @@ namespace ARMeilleure.Instructions
 
             if (op.Coproc != 15)
             {
-                throw new NotImplementedException($"Unknown MRC Coprocessor ID 0x{op.Coproc:X16} at 0x{op.Address:X16}.");
+                InstEmit.Und(context);
+                return;
             }
 
             if (op.Opc1 != 0)
@@ -119,7 +121,8 @@ namespace ARMeilleure.Instructions
 
             if (op.Coproc != 15)
             {
-                throw new NotImplementedException($"Unknown MRC Coprocessor ID 0x{op.Coproc:X16} at 0x{op.Address:X16}.");
+                InstEmit.Und(context);
+                return;
             }
 
             var opc = op.MrrcOp;