Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: aarch64 argument parsing #1544

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions panda/plugins/hypercaller/hypercaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ void unregister_hypercall(uint32_t magic){
uint32_t get_magic(CPUState *cpu){
uint32_t magic;
CPUArchState * env = (CPUArchState *)cpu->env_ptr;
#if defined(TARGET_AARCH64)
//XR
magic = env->xregs[8];
#elif defined(TARGET_ARM)

#if defined(TARGET_ARM)
// r7
magic = env->regs[7];
#if defined(TARGET_AARCH64)
if (env->aarch64 != 0){
// XR
magic = env->xregs[8];
}
#endif
#elif defined(TARGET_MIPS)
// V0
magic = env->active_tc.gpr[2];
Expand Down
19 changes: 19 additions & 0 deletions panda/python/core/pandare/arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,25 @@ def __init__(self, panda):
self.reg_retval = {"default": "X0",
"syscall": "X0",
"linux_kernel": "X0"}
self.arm32 = ArmArch(panda)

def arm32_dec(f, name):
def wrap(*args, **kwargs):
# first check that we have an arg
if len(args) > 0:
# double check that it's a cpustate
cpu = args[0]
if "_cffi_backend" in str(type(cpu)):
# check if we're in arm32 mode
if cpu.env_ptr.aarch64 == 0:
func = getattr(self.arm32, name)
return func(*args, **kwargs)
return f(*args, **kwargs)
return wrap

for attr in dir(self):
if callable(getattr(self, attr)) and not attr.startswith('_'):
setattr(self, attr, arm32_dec(getattr(self, attr), attr))

def get_pc(self, cpu):
'''
Expand Down
Loading