Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[UPSTREAM] RISCV: get_physical_address should not ignore low bits
This resulted in tags always being read/writted for the first capability
of a page. Unsurprisingly, this resulted in many tag violations at run time.
  • Loading branch information
arichardson committed Feb 27, 2020
1 parent 652eace commit 61c8e3f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion target/riscv/cpu_helper.c
Expand Up @@ -339,7 +339,7 @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical,
/* for superpage mappings, make a fake leaf PTE for the TLB's
benefit. */
target_ulong vpn = addr >> PGSHIFT;
*physical = (ppn | (vpn & ((1L << ptshift) - 1))) << PGSHIFT;
*physical = ((ppn | (vpn & ((1L << ptshift) - 1))) << PGSHIFT) | (addr & ~TARGET_PAGE_MASK);

/* set permissions on the TLB entry */
if ((pte & PTE_R) || ((pte & PTE_X) && mxr)) {
Expand Down Expand Up @@ -534,6 +534,7 @@ hwaddr cpu_riscv_translate_address_tagmem(CPUArchState *env,
// TODO: use register
riscv_raise_exception(env, env_cpu(env)->exception_index, retpc);
}
tcg_debug_assert((address & ~TARGET_PAGE_MASK) == (physical &~TARGET_PAGE_MASK));
return physical;
}
#endif /* TARGET_CHERI */
Expand Down

0 comments on commit 61c8e3f

Please sign in to comment.