Skip to content

Commit 852002b

Browse files
mcaylandvivier
authored andcommitted
target/m68k: consolidate physical translation offset into get_physical_address()
Since all callers to get_physical_address() now apply the same page offset to the translation result, move the logic into get_physical_address() itself to avoid duplication. Suggested-by: Philippe Mathieu-Daudé <[email protected]> Signed-off-by: Mark Cave-Ayland <[email protected]> Reviewed-by: Laurent Vivier <[email protected]> Message-Id: <[email protected]> Signed-off-by: Laurent Vivier <[email protected]>
1 parent 7831811 commit 852002b

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

target/m68k/helper.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ static int get_physical_address(CPUM68KState *env, hwaddr *physical,
643643
/* Transparent Translation Register bit */
644644
env->mmu.mmusr = M68K_MMU_T_040 | M68K_MMU_R_040;
645645
}
646-
*physical = address & TARGET_PAGE_MASK;
646+
*physical = address;
647647
*page_size = TARGET_PAGE_SIZE;
648648
return 0;
649649
}
@@ -771,7 +771,7 @@ static int get_physical_address(CPUM68KState *env, hwaddr *physical,
771771
}
772772
*page_size = 1 << page_bits;
773773
page_mask = ~(*page_size - 1);
774-
*physical = next & page_mask;
774+
*physical = (next & page_mask) + (address & (*page_size - 1));
775775

776776
if (access_type & ACCESS_PTEST) {
777777
env->mmu.mmusr |= next & M68K_MMU_SR_MASK_040;
@@ -826,8 +826,6 @@ hwaddr m68k_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
826826
return -1;
827827
}
828828

829-
addr &= TARGET_PAGE_MASK;
830-
phys_addr += addr & (page_size - 1);
831829
return phys_addr;
832830
}
833831

@@ -891,10 +889,8 @@ bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
891889
ret = get_physical_address(&cpu->env, &physical, &prot,
892890
address, access_type, &page_size);
893891
if (likely(ret == 0)) {
894-
address &= TARGET_PAGE_MASK;
895-
physical += address & (page_size - 1);
896-
tlb_set_page(cs, address, physical,
897-
prot, mmu_idx, TARGET_PAGE_SIZE);
892+
tlb_set_page(cs, address & TARGET_PAGE_MASK,
893+
physical & TARGET_PAGE_MASK, prot, mmu_idx, page_size);
898894
return true;
899895
}
900896

@@ -1383,9 +1379,8 @@ void HELPER(ptest)(CPUM68KState *env, uint32_t addr, uint32_t is_read)
13831379
ret = get_physical_address(env, &physical, &prot, addr,
13841380
access_type, &page_size);
13851381
if (ret == 0) {
1386-
addr &= TARGET_PAGE_MASK;
1387-
physical += addr & (page_size - 1);
1388-
tlb_set_page(env_cpu(env), addr, physical,
1382+
tlb_set_page(env_cpu(env), addr & TARGET_PAGE_MASK,
1383+
physical & TARGET_PAGE_MASK,
13891384
prot, access_type & ACCESS_SUPER ?
13901385
MMU_KERNEL_IDX : MMU_USER_IDX, page_size);
13911386
}

0 commit comments

Comments
 (0)