Aarch64 add thread registers (#834)

* add thread registers to AArch64

* update bindings to add AArch64 thread registers

* fix indentation for register read/write switch-case in unicorn_aarch64.c
This commit is contained in:
misson20000 2017-05-14 00:42:49 -07:00 committed by Nguyen Anh Quynh
parent 476553223b
commit 014ccfb94a
7 changed files with 76 additions and 28 deletions

View file

@ -273,7 +273,12 @@ module Arm64 =
// pseudo registers
let UC_ARM64_REG_PC = 260
let UC_ARM64_REG_CPACR_EL1 = 261
let UC_ARM64_REG_ENDING = 262
// thread registers
let UC_ARM64_REG_TPIDR_EL0 = 262
let UC_ARM64_REG_TPIDRRO_EL0 = 263
let UC_ARM64_REG_TPIDR_EL1 = 264
let UC_ARM64_REG_ENDING = 265
// alias registers
let UC_ARM64_REG_IP1 = 215

View file

@ -268,7 +268,12 @@ const (
// pseudo registers
ARM64_REG_PC = 260
ARM64_REG_CPACR_EL1 = 261
ARM64_REG_ENDING = 262
// thread registers
ARM64_REG_TPIDR_EL0 = 262
ARM64_REG_TPIDRRO_EL0 = 263
ARM64_REG_TPIDR_EL1 = 264
ARM64_REG_ENDING = 265
// alias registers
ARM64_REG_IP1 = 215

View file

@ -270,7 +270,12 @@ public interface Arm64Const {
// pseudo registers
public static final int UC_ARM64_REG_PC = 260;
public static final int UC_ARM64_REG_CPACR_EL1 = 261;
public static final int UC_ARM64_REG_ENDING = 262;
// thread registers
public static final int UC_ARM64_REG_TPIDR_EL0 = 262;
public static final int UC_ARM64_REG_TPIDRRO_EL0 = 263;
public static final int UC_ARM64_REG_TPIDR_EL1 = 264;
public static final int UC_ARM64_REG_ENDING = 265;
// alias registers
public static final int UC_ARM64_REG_IP1 = 215;

View file

@ -266,7 +266,12 @@ UC_ARM64_REG_V31 = 259
# pseudo registers
UC_ARM64_REG_PC = 260
UC_ARM64_REG_CPACR_EL1 = 261
UC_ARM64_REG_ENDING = 262
# thread registers
UC_ARM64_REG_TPIDR_EL0 = 262
UC_ARM64_REG_TPIDRRO_EL0 = 263
UC_ARM64_REG_TPIDR_EL1 = 264
UC_ARM64_REG_ENDING = 265
# alias registers
UC_ARM64_REG_IP1 = 215

View file

@ -268,7 +268,12 @@ module Unicorn
# pseudo registers
UC_ARM64_REG_PC = 260
UC_ARM64_REG_CPACR_EL1 = 261
UC_ARM64_REG_ENDING = 262
# thread registers
UC_ARM64_REG_TPIDR_EL0 = 262
UC_ARM64_REG_TPIDRRO_EL0 = 263
UC_ARM64_REG_TPIDR_EL1 = 264
UC_ARM64_REG_ENDING = 265
# alias registers
UC_ARM64_REG_IP1 = 215

View file

@ -282,6 +282,11 @@ typedef enum uc_arm64_reg {
UC_ARM64_REG_CPACR_EL1,
//> thread registers
UC_ARM64_REG_TPIDR_EL0,
UC_ARM64_REG_TPIDRRO_EL0,
UC_ARM64_REG_TPIDR_EL1,
UC_ARM64_REG_ENDING, // <-- mark the end of the list of registers
//> alias registers

View file

@ -79,6 +79,15 @@ int arm64_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int co
case UC_ARM64_REG_CPACR_EL1:
*(uint32_t *)value = ARM_CPU(uc, mycpu)->env.cp15.c1_coproc;
break;
case UC_ARM64_REG_TPIDR_EL0:
*(int64_t *)value = ARM_CPU(uc, mycpu)->env.cp15.tpidr_el0;
break;
case UC_ARM64_REG_TPIDRRO_EL0:
*(int64_t *)value = ARM_CPU(uc, mycpu)->env.cp15.tpidrro_el0;
break;
case UC_ARM64_REG_TPIDR_EL1:
*(int64_t *)value = ARM_CPU(uc, mycpu)->env.cp15.tpidr_el1;
break;
case UC_ARM64_REG_X29:
*(int64_t *)value = ARM_CPU(uc, mycpu)->env.xregs[29];
break;
@ -135,6 +144,15 @@ int arm64_reg_write(struct uc_struct *uc, unsigned int *regs, void* const* vals,
case UC_ARM64_REG_CPACR_EL1:
ARM_CPU(uc, mycpu)->env.cp15.c1_coproc = *(uint32_t *)value;
break;
case UC_ARM64_REG_TPIDR_EL0:
ARM_CPU(uc, mycpu)->env.cp15.tpidr_el0 = *(uint64_t *)value;
break;
case UC_ARM64_REG_TPIDRRO_EL0:
ARM_CPU(uc, mycpu)->env.cp15.tpidrro_el0 = *(uint64_t *)value;
break;
case UC_ARM64_REG_TPIDR_EL1:
ARM_CPU(uc, mycpu)->env.cp15.tpidr_el1 = *(uint64_t *)value;
break;
case UC_ARM64_REG_X29:
ARM_CPU(uc, mycpu)->env.xregs[29] = *(uint64_t *)value;
break;