Fix physical address truncation on 32-bit systems with addressing extensions (#2139)
* use hwaddr for paddrs * Fix the truncation for memory hooks as well * Add LPAE regression test Co-authored-by: Takacs, Philipp <philipp.takacs@iosb.fraunhofer.de>
This commit is contained in:
@@ -956,6 +956,47 @@ static void test_arm_cp15_c1_c0_2(void)
|
||||
OK(uc_close(uc));
|
||||
}
|
||||
|
||||
static bool test_arm_v7_lpae_hook_tlb(uc_engine *uc, uint64_t addr,
|
||||
uc_mem_type type, uc_tlb_entry *result,
|
||||
void *user_data)
|
||||
{
|
||||
result->paddr = addr + 0x100000000;
|
||||
result->perms = UC_PROT_ALL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void test_arm_v7_lpae_hook_read(uc_engine *uc, uc_mem_type type,
|
||||
uint64_t address, int size, uint64_t value,
|
||||
void *user_data)
|
||||
{
|
||||
TEST_CHECK(address == 0x100001000);
|
||||
}
|
||||
|
||||
static void test_arm_v7_lpae(void)
|
||||
{
|
||||
uc_engine *uc;
|
||||
uc_hook hook_read, hook_tlb;
|
||||
uint32_t reg;
|
||||
char code[] = "\x00\x10\x90\xe5"; // ldr r1, [r0]
|
||||
OK(uc_open(UC_ARCH_ARM, UC_MODE_ARM, &uc));
|
||||
OK(uc_ctl_set_cpu_model(uc, UC_CPU_ARM_CORTEX_A7));
|
||||
|
||||
|
||||
OK(uc_ctl_tlb_mode(uc, UC_TLB_VIRTUAL));
|
||||
OK(uc_hook_add(uc, &hook_tlb, UC_HOOK_TLB_FILL, test_arm_v7_lpae_hook_tlb, NULL, 1, 0));
|
||||
OK(uc_hook_add(uc, &hook_read, UC_HOOK_MEM_READ, test_arm_v7_lpae_hook_read, NULL, 1, 0));
|
||||
|
||||
reg = 0x1000;
|
||||
OK(uc_reg_write(uc, UC_ARM_REG_R0, ®));
|
||||
OK(uc_mem_map(uc, 0x100001000, 0x1000, UC_PROT_ALL));
|
||||
OK(uc_mem_write(uc, 0x100001000, code, sizeof(code)));
|
||||
OK(uc_emu_start(uc, 0x1000, 0x1000 + sizeof(code) - 1, 0, 0));
|
||||
OK(uc_reg_read(uc, UC_ARM_REG_R1, ®));
|
||||
TEST_CHECK(reg == 0xe5901000);
|
||||
|
||||
OK(uc_close(uc));
|
||||
}
|
||||
|
||||
TEST_LIST = {{"test_arm_nop", test_arm_nop},
|
||||
{"test_arm_thumb_sub", test_arm_thumb_sub},
|
||||
{"test_armeb_sub", test_armeb_sub},
|
||||
@@ -985,4 +1026,5 @@ TEST_LIST = {{"test_arm_nop", test_arm_nop},
|
||||
{"test_arm_tcg_opcode_cmp", test_arm_tcg_opcode_cmp},
|
||||
{"test_arm_thumb_tcg_opcode_cmn", test_arm_thumb_tcg_opcode_cmn},
|
||||
{"test_arm_cp15_c1_c0_2", test_arm_cp15_c1_c0_2},
|
||||
{"test_arm_v7_lpae", test_arm_v7_lpae},
|
||||
{NULL, NULL}};
|
||||
|
||||
Reference in New Issue
Block a user