target/riscv: use hash table as set for user_options
The values stored in user_options are never retrieved, only key presence is checked. Use g_hash_table_add() instead of g_hash_table_insert() and drop the unused value parameter. Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Marc-André Lureau committed
May 4, 2026 at 14:24 UTC
1b563a072960f2b02f09628ce231abc1798e6e3c
1 file changed
+15
-17
target/riscv/cpu.c
+15
-17
@@ -60,11 +60,9 @@ bool riscv_cpu_is_32bit(RISCVCPU *cpu)
60
return riscv_cpu_mxl(&cpu->env) == MXL_RV32;
61
}
62
63
-static void cpu_option_add_user_setting(RISCVCPU *cpu, const char *optname,
64
- uint32_t value)
63
+static void cpu_option_add_user_setting(RISCVCPU *cpu, const char *optname)
64
{
66
- g_hash_table_insert(cpu->user_options, (gpointer)optname,
67
- GUINT_TO_POINTER(value));
65
+ g_hash_table_add(cpu->user_options, (gpointer)optname);
66
}
67
68
bool riscv_cpu_option_set(RISCVCPU *cpu, const char *optname)
@@ -1290,7 +1288,7 @@ static void prop_pmu_num_set(Object *obj, Visitor *v, const char *name,
1288
1289
warn_report("\"pmu-num\" property is deprecated; use \"pmu-mask\"");
1290
cpu->cfg.pmu_mask = pmu_mask;
1293
- cpu_option_add_user_setting(cpu, "pmu-mask", pmu_mask);
1291
+ cpu_option_add_user_setting(cpu, "pmu-mask");
1292
}
1293
1294
static void prop_pmu_num_get(Object *obj, Visitor *v, const char *name,
@@ -1332,7 +1330,7 @@ static void prop_pmu_mask_set(Object *obj, Visitor *v, const char *name,
1330
return;
1331
}
1332
1335
- cpu_option_add_user_setting(cpu, name, value);
1333
+ cpu_option_add_user_setting(cpu, name);
1334
cpu->cfg.pmu_mask = value;
1335
}
1336
@@ -1364,7 +1362,7 @@ static void prop_mmu_set(Object *obj, Visitor *v, const char *name,
1362
return;
1363
}
1364
1367
- cpu_option_add_user_setting(cpu, name, value);
1365
+ cpu_option_add_user_setting(cpu, name);
1366
cpu->cfg.mmu = value;
1367
}
1368
@@ -1396,7 +1394,7 @@ static void prop_pmp_set(Object *obj, Visitor *v, const char *name,
1394
return;
1395
}
1396
1399
- cpu_option_add_user_setting(cpu, name, value);
1397
+ cpu_option_add_user_setting(cpu, name);
1398
cpu->cfg.pmp = value;
1399
}
1400
@@ -1436,7 +1434,7 @@ static void prop_num_pmp_regions_set(Object *obj, Visitor *v, const char *name,
1434
return;
1435
}
1436
1439
- cpu_option_add_user_setting(cpu, name, value);
1437
+ cpu_option_add_user_setting(cpu, name);
1438
cpu->cfg.pmp_regions = value;
1439
}
1440
@@ -1474,7 +1472,7 @@ static void prop_pmp_granularity_set(Object *obj, Visitor *v, const char *name,
1472
return;
1473
}
1474
1477
- cpu_option_add_user_setting(cpu, name, value);
1475
+ cpu_option_add_user_setting(cpu, name);
1476
cpu->cfg.pmp_granularity = value;
1477
}
1478
@@ -1547,7 +1545,7 @@ static void prop_priv_spec_set(Object *obj, Visitor *v, const char *name,
1545
return;
1546
}
1547
1550
- cpu_option_add_user_setting(cpu, name, priv_version);
1548
+ cpu_option_add_user_setting(cpu, name);
1549
cpu->env.priv_ver = priv_version;
1550
}
1551
@@ -1581,7 +1579,7 @@ static void prop_vext_spec_set(Object *obj, Visitor *v, const char *name,
1579
return;
1580
}
1581
1584
- cpu_option_add_user_setting(cpu, name, VEXT_VERSION_1_00_0);
1582
+ cpu_option_add_user_setting(cpu, name);
1583
cpu->env.vext_ver = VEXT_VERSION_1_00_0;
1584
}
1585
@@ -1624,7 +1622,7 @@ static void prop_vlen_set(Object *obj, Visitor *v, const char *name,
1622
return;
1623
}
1624
1627
- cpu_option_add_user_setting(cpu, name, value);
1625
+ cpu_option_add_user_setting(cpu, name);
1626
cpu->cfg.vlenb = value >> 3;
1627
}
1628
@@ -1665,7 +1663,7 @@ static void prop_elen_set(Object *obj, Visitor *v, const char *name,
1663
return;
1664
}
1665
1668
- cpu_option_add_user_setting(cpu, name, value);
1666
+ cpu_option_add_user_setting(cpu, name);
1667
cpu->cfg.elen = value;
1668
}
1669
@@ -1701,7 +1699,7 @@ static void prop_cbom_blksize_set(Object *obj, Visitor *v, const char *name,
1699
return;
1700
}
1701
1704
- cpu_option_add_user_setting(cpu, name, value);
1702
+ cpu_option_add_user_setting(cpu, name);
1703
cpu->cfg.cbom_blocksize = value;
1704
}
1705
@@ -1737,7 +1735,7 @@ static void prop_cbop_blksize_set(Object *obj, Visitor *v, const char *name,
1735
return;
1736
}
1737
1740
- cpu_option_add_user_setting(cpu, name, value);
1738
+ cpu_option_add_user_setting(cpu, name);
1739
cpu->cfg.cbop_blocksize = value;
1740
}
1741
@@ -1773,7 +1771,7 @@ static void prop_cboz_blksize_set(Object *obj, Visitor *v, const char *name,
1771
return;
1772
}
1773
1776
- cpu_option_add_user_setting(cpu, name, value);
1774
+ cpu_option_add_user_setting(cpu, name);
1775
cpu->cfg.cboz_blocksize = value;
1776
}
1777