From 42ddc543ed4a64b7f8ebf8035e6ee4b1ab569f1b Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Thu, 19 Jan 2023 17:21:06 -0800 Subject: Perform pmpregions input validation in only one place No reason to check it both in sim_t::sim_t and in processor_t::set_pmp_num. --- riscv/sim.cc | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/riscv/sim.cc b/riscv/sim.cc index 74b3523..051a483 100644 --- a/riscv/sim.cc +++ b/riscv/sim.cc @@ -156,20 +156,10 @@ sim_t::sim_t(const cfg_t *cfg, bool halted, break; //handle pmp - reg_t pmp_num = 0, pmp_granularity = 0; - if (fdt_parse_pmp_num(fdt, cpu_offset, &pmp_num) == 0) { - if (pmp_num <= 64) { - procs[cpu_idx]->set_pmp_num(pmp_num); - } else { - std::cerr << "core (" - << cpu_idx - << ") doesn't have valid 'riscv,pmpregions'" - << pmp_num << ").\n"; - exit(1); - } - } else { - procs[cpu_idx]->set_pmp_num(0); - } + reg_t pmp_num, pmp_granularity; + if (fdt_parse_pmp_num(fdt, cpu_offset, &pmp_num) != 0) + pmp_num = 0; + procs[cpu_idx]->set_pmp_num(pmp_num); if (fdt_parse_pmp_alignment(fdt, cpu_offset, &pmp_granularity) == 0) { procs[cpu_idx]->set_pmp_granularity(pmp_granularity); -- cgit v1.1