src/target/riscv:fix virt2phys

Change-Id: I6b92fcd3a6764b98c9e4f8c19a197bb253d6471a
Signed-off-by: wangyanwen <wangyanwen@nucleisys.com>
This commit is contained in:
wangyanwen 2025-02-14 18:22:19 +08:00
parent c7ad945ad5
commit 494eca14c4
1 changed files with 2 additions and 8 deletions

View File

@ -2987,11 +2987,8 @@ static int riscv_address_translate(struct target *target,
LOG_TARGET_DEBUG(target, "i=%d; PTE @0x%" TARGET_PRIxADDR " = 0x%" PRIx64, i,
pte_address, pte);
if (!(pte & PTE_V) || (!(pte & PTE_R) && (pte & PTE_W))) {
LOG_TARGET_ERROR(target, "invalid PTE @0x%" TARGET_PRIxADDR ": 0x%" PRIx64
"; mode=%s; i=%d", pte_address, pte, info->name, i);
if (!(pte & PTE_V) || (!(pte & PTE_R) && (pte & PTE_W)))
return ERROR_FAIL;
}
if ((pte & PTE_R) || (pte & PTE_W) || (pte & PTE_X)) /* Found leaf PTE. */
break;
@ -3301,11 +3298,8 @@ static int riscv_rw_memory(struct target *target, const riscv_mem_access_args_t
while (current_count < args.count) {
target_addr_t physical_addr;
result = target->type->virt2phys(target, current_address, &physical_addr);
if (result != ERROR_OK) {
LOG_TARGET_ERROR(target, "Address translation failed.");
if (result != ERROR_OK)
physical_addr = current_address;
//return result;
}
/* TODO: For simplicity, this algorithm assumes the worst case - the smallest possible page size,
* which is 4 KiB. The algorithm can be improved to detect the real page size, and allow to use larger