Skip to content

Commit 1a01276

Browse files
committed
virtual read handle sparc mmu
The sparc mmu currently doesn't support probe mode which is used by uc_mem_read_virtual. So for now return UC_ERR_ARG when the sparc mmu is used.
1 parent 5fd89eb commit 1a01276

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

tests/unit/test_sparc.c

+17-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,20 @@
33
const uint64_t code_start = 0x1000;
44
const uint64_t code_len = 0x4000;
55

6-
TEST_LIST = {{NULL, NULL}};
6+
static void test_virtual_read(void)
7+
{
8+
uc_engine *uc;
9+
uint8_t u8 = 8;
10+
11+
OK(uc_open(UC_ARCH_SPARC, UC_MODE_SPARC32|UC_MODE_BIG_ENDIAN, &uc));
12+
OK(uc_mem_map(uc, code_start, code_len, UC_PROT_ALL));
13+
14+
uc_assert_err(UC_ERR_ARG, uc_mem_read_virtual(uc, code_start, UC_PROT_READ, &u8, sizeof(u8)));
15+
OK(uc_ctl_tlb_mode(uc, UC_TLB_VIRTUAL));
16+
OK(uc_mem_read_virtual(uc, code_start, UC_PROT_READ, &u8, sizeof(u8)));
17+
}
18+
19+
TEST_LIST = {
20+
{"test_virtual_read", test_virtual_read},
21+
{NULL, NULL}
22+
};

uc.c

+6
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,12 @@ uc_err uc_mem_read_virtual(uc_engine *uc, uint64_t address, uc_prot prot,
790790
return UC_ERR_ARG;
791791
}
792792

793+
// The sparc mmu doesn't support probe mode
794+
if (uc->arch == UC_ARCH_SPARC && uc->cpu->cc->tlb_fill == uc->cpu->cc->tlb_fill_cpu) {
795+
restore_jit_state(uc);
796+
return UC_ERR_ARG;
797+
}
798+
793799
if (!(UC_PROT_READ == prot || UC_PROT_WRITE == prot ||
794800
UC_PROT_EXEC == prot)) {
795801
restore_jit_state(uc);

0 commit comments

Comments
 (0)