Skip to content

Commit 52f045d

Browse files
committed
Lift restriction on physical-address size
It remains true that PTEs can only represent addresses >= 2^56, but there's no need to impose that constraint on untranslated accesses.
1 parent 1687094 commit 52f045d

File tree

3 files changed

+4
-18
lines changed

3 files changed

+4
-18
lines changed

riscv/mmu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define PGSHIFT 12
2020
const reg_t PGSIZE = 1 << PGSHIFT;
2121
const reg_t PGMASK = ~(PGSIZE-1);
22-
#define MAX_PADDR_BITS 56 // imposed by Sv39 / Sv48
22+
#define MAX_PADDR_BITS 64
2323

2424
struct insn_fetch_t
2525
{

riscv/sim.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ void sim_t::set_procs_debug(bool value)
322322

323323
static bool paddr_ok(reg_t addr)
324324
{
325-
return (addr >> MAX_PADDR_BITS) == 0;
325+
static_assert(MAX_PADDR_BITS == 8 * sizeof(addr));
326+
return true;
326327
}
327328

328329
bool sim_t::mmio_load(reg_t paddr, size_t len, uint8_t* bytes)

spike_main/spike.cc

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -213,22 +213,7 @@ static mem_cfg_t create_mem_region(unsigned long long base, unsigned long long s
213213
exit(EXIT_FAILURE);
214214
}
215215

216-
const unsigned long long max_allowed_pa = (1ull << MAX_PADDR_BITS) - 1ull;
217-
assert(max_allowed_pa <= std::numeric_limits<reg_t>::max());
218-
mem_cfg_t mem_region(base, size);
219-
if (mem_region.get_inclusive_end() > max_allowed_pa) {
220-
int bits_required = 64 - clz(mem_region.get_inclusive_end());
221-
fprintf(stderr, "Unsupported memory region "
222-
"{base = 0x%" PRIX64 ", size = 0x%" PRIX64 "} specified,"
223-
" which requires %d bits of physical address\n"
224-
" The largest accessible physical address "
225-
"is 0x%llX (defined by MAX_PADDR_BITS constant, which is %d)\n",
226-
mem_region.get_base(), mem_region.get_size(), bits_required,
227-
max_allowed_pa, MAX_PADDR_BITS);
228-
exit(EXIT_FAILURE);
229-
}
230-
231-
return mem_region;
216+
return mem_cfg_t(base, size);
232217
}
233218

234219
static std::vector<mem_cfg_t> parse_mem_layout(const char* arg)

0 commit comments

Comments
 (0)