diff --git a/panda/python/core/pandare/arch.py b/panda/python/core/pandare/arch.py index 381f18b01c4..6bd7d0926d2 100644 --- a/panda/python/core/pandare/arch.py +++ b/panda/python/core/pandare/arch.py @@ -250,7 +250,11 @@ def get_retval(self, cpu, convention='default'): rv = self.get_reg(cpu, reg) if convention == 'syscall': - rv = self.panda.from_unsigned_guest(rv) + bits = None + if self.panda.arch_name == "aarch64": + if cpu.env_ptr.aarch64 == 0: + bits = 32 + rv = self.panda.from_unsigned_guest(rv, bits=bits) return rv diff --git a/panda/python/core/pandare/panda.py b/panda/python/core/pandare/panda.py index 01307a3029c..0fab0a80872 100644 --- a/panda/python/core/pandare/panda.py +++ b/panda/python/core/pandare/panda.py @@ -1057,7 +1057,7 @@ def to_unsigned_guest(self, x): else: raise ValueError("Unsupported number of bits") - def from_unsigned_guest(self, x): + def from_unsigned_guest(self, x, bits=None): ''' Convert an unsigned int32/unsigned int64 from the guest (depending on guest bit-size) to a (signed) python int @@ -1068,8 +1068,10 @@ def from_unsigned_guest(self, x): Returns: int: Python integer representing x as a signed value ''' - if x >= 2**(self.bits-1): # If highest bit is set, it's negative - return (x - 2**self.bits) + if bits is None: + bits = self.bits + if x >= 2**(bits-1): # If highest bit is set, it's negative + return (x - 2**bits) else: # Else it's positive return x