Browse Source
Merge pull request #2037 from riscv-software-src/2036-redux
Only support 56-bit PMP and ATP addresses
pull/2039/head
Andrew Waterman
10 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with
6 additions and
22 deletions
-
riscv/csrs.cc
-
riscv/mmu.h
-
riscv/processor.cc
-
riscv/processor.h
-
riscv/sim.cc
|
|
|
@ -121,7 +121,7 @@ bool pmpaddr_csr_t::unlogged_write(const reg_t val) noexcept { |
|
|
|
const bool locked = !lock_bypass && (cfg & PMP_L); |
|
|
|
|
|
|
|
if (pmpidx < proc->n_pmp && !locked && !next_locked_and_tor()) { |
|
|
|
this->val = val & ((reg_t(1) << (MAX_PADDR_BITS - PMP_SHIFT)) - 1); |
|
|
|
this->val = val & ((reg_t(1) << (proc->paddr_bits() - PMP_SHIFT)) - 1); |
|
|
|
} |
|
|
|
else |
|
|
|
return false; |
|
|
|
@ -1098,7 +1098,7 @@ bool base_atp_csr_t::satp_valid(reg_t val) const noexcept { |
|
|
|
} |
|
|
|
|
|
|
|
reg_t base_atp_csr_t::compute_new_satp(reg_t val) const noexcept { |
|
|
|
reg_t rv64_ppn_mask = (reg_t(1) << (MAX_PADDR_BITS - PGSHIFT)) - 1; |
|
|
|
reg_t rv64_ppn_mask = (reg_t(1) << (proc->paddr_bits() - PGSHIFT)) - 1; |
|
|
|
|
|
|
|
reg_t mode_mask = proc->get_xlen() == 32 ? SATP32_MODE : SATP64_MODE; |
|
|
|
reg_t asid_mask_if_enabled = proc->get_xlen() == 32 ? SATP32_ASID : SATP64_ASID; |
|
|
|
@ -1326,7 +1326,7 @@ bool hgatp_csr_t::unlogged_write(const reg_t val) noexcept { |
|
|
|
HGATP32_MODE | |
|
|
|
(proc->supports_impl(IMPL_MMU_VMID) ? HGATP32_VMID : 0); |
|
|
|
} else { |
|
|
|
mask = (HGATP64_PPN & ((reg_t(1) << (MAX_PADDR_BITS - PGSHIFT)) - 1)) | |
|
|
|
mask = (HGATP64_PPN & ((reg_t(1) << (proc->paddr_bits() - PGSHIFT)) - 1)) | |
|
|
|
(proc->supports_impl(IMPL_MMU_VMID) ? HGATP64_VMID : 0); |
|
|
|
|
|
|
|
if (get_field(val, HGATP64_MODE) == HGATP_MODE_OFF || |
|
|
|
|
|
|
|
@ -18,7 +18,6 @@ |
|
|
|
// virtual memory configuration
|
|
|
|
#define PGSHIFT 12 |
|
|
|
const reg_t PGSIZE = 1 << PGSHIFT; |
|
|
|
#define MAX_PADDR_BITS 64 |
|
|
|
|
|
|
|
// observability hooks for load, store and fetch
|
|
|
|
// intentionally empty not to cause runtime overhead
|
|
|
|
|
|
|
|
@ -607,13 +607,6 @@ void processor_t::disasm(insn_t insn) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int processor_t::paddr_bits() |
|
|
|
{ |
|
|
|
unsigned max_xlen = isa.get_max_xlen(); |
|
|
|
assert(xlen == max_xlen); |
|
|
|
return max_xlen == 64 ? 50 : 34; |
|
|
|
} |
|
|
|
|
|
|
|
void processor_t::put_csr(int which, reg_t val) |
|
|
|
{ |
|
|
|
val = zext_xlen(val); |
|
|
|
|
|
|
|
@ -273,6 +273,7 @@ public: |
|
|
|
mmu_t* get_mmu() { return mmu; } |
|
|
|
state_t* get_state() { return &state; } |
|
|
|
unsigned get_xlen() const { return xlen; } |
|
|
|
unsigned paddr_bits() { return isa.get_max_xlen() == 64 ? 56 : 34; } |
|
|
|
unsigned get_const_xlen() const { |
|
|
|
// Any code that assumes a const xlen should use this method to
|
|
|
|
// document that assumption. If Spike ever changes to allow
|
|
|
|
@ -421,7 +422,6 @@ private: |
|
|
|
void take_trigger_action(triggers::action_t action, reg_t breakpoint_tval, reg_t epc, bool virt); |
|
|
|
void disasm(insn_t insn); // disassemble and print an instruction
|
|
|
|
void register_insn(insn_desc_t, bool); |
|
|
|
int paddr_bits(); |
|
|
|
|
|
|
|
void enter_debug_mode(uint8_t cause, uint8_t ext_cause); |
|
|
|
|
|
|
|
|
|
|
|
@ -337,22 +337,16 @@ void sim_t::set_procs_debug(bool value) |
|
|
|
procs[i]->set_debug(value); |
|
|
|
} |
|
|
|
|
|
|
|
static bool paddr_ok(reg_t addr) |
|
|
|
{ |
|
|
|
static_assert(MAX_PADDR_BITS == 8 * sizeof(addr)); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
bool sim_t::mmio_load(reg_t paddr, size_t len, uint8_t* bytes) |
|
|
|
{ |
|
|
|
if (paddr + len < paddr || !paddr_ok(paddr + len - 1)) |
|
|
|
if (paddr + len < paddr) |
|
|
|
return false; |
|
|
|
return bus.load(paddr, len, bytes); |
|
|
|
} |
|
|
|
|
|
|
|
bool sim_t::mmio_store(reg_t paddr, size_t len, const uint8_t* bytes) |
|
|
|
{ |
|
|
|
if (paddr + len < paddr || !paddr_ok(paddr + len - 1)) |
|
|
|
if (paddr + len < paddr) |
|
|
|
return false; |
|
|
|
return bus.store(paddr, len, bytes); |
|
|
|
} |
|
|
|
@ -403,8 +397,6 @@ void sim_t::set_rom() |
|
|
|
} |
|
|
|
|
|
|
|
char* sim_t::addr_to_mem(reg_t paddr) { |
|
|
|
if (!paddr_ok(paddr)) |
|
|
|
return NULL; |
|
|
|
auto desc = bus.find_device(paddr >> PGSHIFT << PGSHIFT, PGSIZE); |
|
|
|
if (auto mem = dynamic_cast<abstract_mem_t*>(desc.second)) |
|
|
|
return mem->contents(paddr - desc.first); |
|
|
|
|