cpu->cfg.cbop_blocksize = 64;
cpu->cfg.cboz_blocksize = 64;
cpu->cfg.pmp_regions = 16;
+ cpu->cfg.pmp_granularity = MIN_RISCV_PMP_GRANULARITY;
cpu->env.vext_ver = VEXT_VERSION_1_00_0;
cpu->cfg.max_satp_mode = -1;
.set = prop_num_pmp_regions_set,
};
+static void prop_pmp_granularity_set(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
+{
+ RISCVCPU *cpu = RISCV_CPU(obj);
+ uint32_t value;
+
+ visit_type_uint32(v, name, &value, errp);
+
+ if ((value < MIN_RISCV_PMP_GRANULARITY) && (value & (value - 1))) {
+ error_setg(errp, "PMP granularity must be a power of 2 and at least %d",
+ MIN_RISCV_PMP_GRANULARITY);
+ return;
+ }
+
+ if (cpu->cfg.pmp_granularity != value && riscv_cpu_is_vendor(obj)) {
+ cpu_set_prop_err(cpu, name, errp);
+ return;
+ }
+
+ cpu_option_add_user_setting(name, value);
+ cpu->cfg.pmp_granularity = value;
+}
+
+static void prop_pmp_granularity_get(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
+{
+ uint32_t value = RISCV_CPU(obj)->cfg.pmp_granularity;
+
+ visit_type_uint32(v, name, &value, errp);
+}
+
+static const PropertyInfo prop_pmp_granularity = {
+ .description = "pmp-granularity",
+ .get = prop_pmp_granularity_get,
+ .set = prop_pmp_granularity_set,
+};
+
static int priv_spec_from_str(const char *priv_spec_str)
{
int priv_version = -1;
{.name = "mmu", .info = &prop_mmu},
{.name = "pmp", .info = &prop_pmp},
{.name = "num-pmp-regions", .info = &prop_num_pmp_regions},
+ {.name = "pmp-granularity", .info = &prop_pmp_granularity},
{.name = "priv_spec", .info = &prop_priv_spec},
{.name = "vext_spec", .info = &prop_vext_spec},