Skip to content

Commit 1875140

Browse files
committed
target/riscv: fix riscv_mmu behaviour
Fixed riscv_mmu behaviour: buggy check was removed. As a result virt2phys command behaviour was fixed: now it returns translated address even while virt2phys_mode is off. Change-Id: Ie2e6d1057024ab794038d5ed3662ef49a4d71e70 Signed-off-by: Farid Khaydari <f.khaydari@syntacore.com>
1 parent 1aebdf8 commit 1875140

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/target/riscv/riscv.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3017,9 +3017,6 @@ static int riscv_mmu(struct target *target, int *enabled)
30173017
{
30183018
*enabled = 0;
30193019

3020-
if (!riscv_virt2phys_mode_is_sw(target))
3021-
return ERROR_OK;
3022-
30233020
/* Don't use MMU in explicit or effective M (machine) mode */
30243021
riscv_reg_t priv;
30253022
if (riscv_reg_get(target, &priv, GDB_REGNO_PRIV) != ERROR_OK) {
@@ -3425,16 +3422,11 @@ static int riscv_rw_memory(struct target *target, const riscv_mem_access_args_t
34253422
return ERROR_OK;
34263423
}
34273424

3428-
int mmu_enabled;
3429-
int result = riscv_mmu(target, &mmu_enabled);
3430-
if (result != ERROR_OK)
3431-
return result;
3432-
34333425
RISCV_INFO(r);
3434-
if (!mmu_enabled)
3426+
if (riscv_virt2phys_mode_is_hw(target))
34353427
return r->access_memory(target, args);
34363428

3437-
result = check_virt_memory_access(target, args.address,
3429+
int result = check_virt_memory_access(target, args.address,
34383430
args.size, args.count, is_write);
34393431
if (result != ERROR_OK)
34403432
return result;

0 commit comments

Comments
 (0)