diff --git a/proxyclient/experiments/dart_dump.py b/proxyclient/experiments/dart_dump.py index 2278b8ea..0c797ed3 100755 --- a/proxyclient/experiments/dart_dump.py +++ b/proxyclient/experiments/dart_dump.py @@ -52,7 +52,7 @@ class DART(RegMap): TTBR3 = irange(0x20c, 16, 16), R_TTBR def __init__(self, base): - super().__init__(p, base) + super().__init__(u, base) self.base = base def dump_table2(self, base, l1_addr): diff --git a/proxyclient/m1n1/hv.py b/proxyclient/m1n1/hv.py index 95d8de7e..267851e5 100644 --- a/proxyclient/m1n1/hv.py +++ b/proxyclient/m1n1/hv.py @@ -130,21 +130,7 @@ class HV(Reloadable): "p": self.p, "u": self.u, "TraceMode": TraceMode, - } - self.mmio_rd = [ - lambda addr: [proxy.read8(addr)], - lambda addr: [proxy.read16(addr)], - lambda addr: [proxy.read32(addr)], - lambda addr: [proxy.read64(addr)], - lambda addr: [proxy.read64(addr), proxy.read64(addr + 8)], - ] - self.mmio_wr = [ - lambda addr, data: proxy.write8(addr, data), - lambda addr, data: proxy.write16(addr, data), - lambda addr, data: proxy.write32(addr, data), - lambda addr, data: proxy.write64(addr, data), - lambda addr, data: (proxy.write64(addr, data[0]), proxy.write64(addr + 8, data[1])), - ] + }) for attr in dir(self): a = getattr(self, attr) @@ -336,9 +322,11 @@ class HV(Reloadable): first += 1 elif mode == TraceMode.SYNC: if data.flags.WRITE: - self.mmio_wr[data.flags.WIDTH](data.addr, wval) + self.u.write(data.addr, wval, 8 << data.flags.WIDTH) else: - val = self.mmio_rd[data.flags.WIDTH](data.addr) + val = self.u.read(data.addr, 8 << data.flags.WIDTH) + if not isinstance(val, list) and not isinstance(val, tuple): + val = [val] else: raise Exception(f"VM hook with unexpected mapping at {data.addr:#x}: {maps[0][0].name}") diff --git a/proxyclient/m1n1/proxyutils.py b/proxyclient/m1n1/proxyutils.py index 86bcd670..d7254bdb 100644 --- a/proxyclient/m1n1/proxyutils.py +++ b/proxyclient/m1n1/proxyutils.py @@ -68,6 +68,33 @@ class ProxyUtils(Reloadable): "gl2": (self.proxy.gl2_call, REGION_RX_EL1), "gl1": (self.proxy.gl1_call, 0), } + self._read = { + 8: lambda addr: self.proxy.read8(addr), + 16: lambda addr: self.proxy.read16(addr), + 32: lambda addr: self.proxy.read32(addr), + 64: lambda addr: self.proxy.read64(addr), + 128: lambda addr: [self.proxy.read64(addr), + self.proxy.read64(addr + 8)], + } + self._write = { + 8: lambda addr, data: self.proxy.write8(addr, data), + 16: lambda addr, data: self.proxy.write16(addr, data), + 32: lambda addr, data: self.proxy.write32(addr, data), + 64: lambda addr, data: self.proxy.write64(addr, data), + 128: lambda addr, data: (self.proxy.write64(addr, data[0]), + self.proxy.write64(addr + 8, data[1])), + } + + def read(self, addr, width): + val = self._read[width](addr) + if self.proxy.get_exc_count(): + raise ProxyError("Exception occurred") + return val + + def write(self, addr, data, width): + self._write[width](addr, data) + if self.proxy.get_exc_count(): + raise ProxyError("Exception occurred") def mrs(self, reg, *, silent=False, call=None): op0, op1, CRn, CRm, op2 = sysreg_parse(reg) diff --git a/proxyclient/m1n1/utils.py b/proxyclient/m1n1/utils.py index c206dfe8..d7e0e9fb 100644 --- a/proxyclient/m1n1/utils.py +++ b/proxyclient/m1n1/utils.py @@ -558,8 +558,8 @@ class RegMap(Reloadable, metaclass=RegMeta): for name, (addr, rcls) in self._namemap.items(): width = rcls.__WIDTH__ - rd = getattr(backend, f"read{width}") - wr = getattr(backend, f"write{width}") + rd = lambda addr: backend.read(addr, width) + wr = lambda addr, data: backend.write(addr, data, width) if isinstance(addr, range): self._accessor[name] = RegArrayAccessor(addr, rcls, rd, wr, base) else: