Don't propagate failure to read satp in riscv_mmu() (#466)

If we return failure, then the caller will think something's wrong. But
it could very well be that the hardware doesn't have SATP, in which case
we should just report that the MMU is disabled.

This fixes a bug where flashing wasn't using the target algorithm
because allocating a work area failed.

Change-Id: I16e8e660036d3f8584c0b17e842c4ec8961a8410
regcache
Tim Newsome 2020-04-13 12:53:26 -07:00 committed by GitHub
parent 464407cfd2
commit 2e9aad8914
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -1382,10 +1382,11 @@ static int riscv_mmu(struct target *target, int *enabled)
riscv_set_current_hartid(target, target->rtos->current_thread - 1); riscv_set_current_hartid(target, target->rtos->current_thread - 1);
riscv_reg_t value; riscv_reg_t value;
int result = riscv_get_register(target, &value, GDB_REGNO_SATP); if (riscv_get_register(target, &value, GDB_REGNO_SATP) != ERROR_OK) {
if (result != ERROR_OK) {
LOG_DEBUG("Couldn't read SATP."); LOG_DEBUG("Couldn't read SATP.");
return result; /* If we can't read SATP, then there must not be an MMU. */
*enabled = 0;
return ERROR_OK;
} }
if (get_field(value, RISCV_SATP_MODE(riscv_xlen(target))) == SATP_MODE_OFF) { if (get_field(value, RISCV_SATP_MODE(riscv_xlen(target))) == SATP_MODE_OFF) {