mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-03-24 22:35:16 +00:00
mips: Decide to map PAGE_EXEC in map_address
This commit addresses QEMU Bug #1825311: mips_cpu_handle_mmu_fault renders all accessed pages executable It allows finer-grained control over whether the accessed page should be executable by moving the decision to the underlying map_address function, which has more information for this. As a result, pages that have the XI bit set in the TLB and are accessed for read/write, don't suddenly end up being executable. Fixes: https://bugs.launchpad.net/qemu/+bug/1825311 Fixes: 2fb58b73746e ('target-mips: add RI and XI fields to TLB entry') Backports commit 7353113fa482e697a77575086a41f429a01f8dc0 from qemu
This commit is contained in:
parent
9e8aed043e
commit
5b25eb80af
|
@ -42,7 +42,7 @@ int no_mmu_map_address (CPUMIPSState *env, hwaddr *physical, int *prot,
|
||||||
target_ulong address, int rw, int access_type)
|
target_ulong address, int rw, int access_type)
|
||||||
{
|
{
|
||||||
*physical = address;
|
*physical = address;
|
||||||
*prot = PAGE_READ | PAGE_WRITE;
|
*prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
|
||||||
return TLBRET_MATCH;
|
return TLBRET_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ int fixed_mmu_map_address (CPUMIPSState *env, hwaddr *physical, int *prot,
|
||||||
else
|
else
|
||||||
*physical = address;
|
*physical = address;
|
||||||
|
|
||||||
*prot = PAGE_READ | PAGE_WRITE;
|
*prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
|
||||||
return TLBRET_MATCH;
|
return TLBRET_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +100,9 @@ int r4k_map_address (CPUMIPSState *env, hwaddr *physical, int *prot,
|
||||||
*prot = PAGE_READ;
|
*prot = PAGE_READ;
|
||||||
if (n ? tlb->D1 : tlb->D0)
|
if (n ? tlb->D1 : tlb->D0)
|
||||||
*prot |= PAGE_WRITE;
|
*prot |= PAGE_WRITE;
|
||||||
|
if (!(n ? tlb->XI1 : tlb->XI0)) {
|
||||||
|
*prot |= PAGE_EXEC;
|
||||||
|
}
|
||||||
return TLBRET_MATCH;
|
return TLBRET_MATCH;
|
||||||
}
|
}
|
||||||
return TLBRET_DIRTY;
|
return TLBRET_DIRTY;
|
||||||
|
@ -181,7 +184,7 @@ static int get_seg_physical_address(CPUMIPSState *env, hwaddr *physical,
|
||||||
} else {
|
} else {
|
||||||
/* The segment is unmapped */
|
/* The segment is unmapped */
|
||||||
*physical = physical_base | (real_address & segmask);
|
*physical = physical_base | (real_address & segmask);
|
||||||
*prot = PAGE_READ | PAGE_WRITE;
|
*prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
|
||||||
return TLBRET_MATCH;
|
return TLBRET_MATCH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -895,7 +898,7 @@ bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
|
||||||
}
|
}
|
||||||
if (ret == TLBRET_MATCH) {
|
if (ret == TLBRET_MATCH) {
|
||||||
tlb_set_page(cs, address & TARGET_PAGE_MASK,
|
tlb_set_page(cs, address & TARGET_PAGE_MASK,
|
||||||
physical & TARGET_PAGE_MASK, prot | PAGE_EXEC,
|
physical & TARGET_PAGE_MASK, prot,
|
||||||
mmu_idx, TARGET_PAGE_SIZE);
|
mmu_idx, TARGET_PAGE_SIZE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -915,7 +918,7 @@ bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
|
||||||
access_type, mips_access_type, mmu_idx);
|
access_type, mips_access_type, mmu_idx);
|
||||||
if (ret == TLBRET_MATCH) {
|
if (ret == TLBRET_MATCH) {
|
||||||
tlb_set_page(cs, address & TARGET_PAGE_MASK,
|
tlb_set_page(cs, address & TARGET_PAGE_MASK,
|
||||||
physical & TARGET_PAGE_MASK, prot | PAGE_EXEC,
|
physical & TARGET_PAGE_MASK, prot,
|
||||||
mmu_idx, TARGET_PAGE_SIZE);
|
mmu_idx, TARGET_PAGE_SIZE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue