DEFINE_PROP_UINT64_CHECKMASK is designed to detect and check user's
property setting:
* checking: check property value against a bitmask.
* detection: ask caller to provide an invalid value as the initial
"sentinel" value, which is impossible to be set by users. However,
this detection is not strict, since the property could be also
set internally.
The entire mechanism is not easy to use.
Now there's USER_SET flag in place (and the current unique use case
"lbr-fmt" has been converted to checking USER_SET way), manual setting
of invalid initial values is no longer required.
Thus, extend DEFINE_PROP_UINT64_CHECKMASK to support *valid* default
value, and for "lbr-fmt" case, replace the invalid initialization value
`~PERF_CAP_LBR_FMT` with a valid value `0`.
In addition, considering DEFINE_PROP_UINT64_CHECKMASK itself actually
doesn't identify whether the property is set by the user or not, remove
"user-supplied" related description in its document.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
hw/core/qdev-properties.c | 1 +
include/hw/core/qdev-properties.h | 14 +++++++-------
target/i386/cpu.c | 4 +---
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 91c4010e7dc9..b84214e60f19 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -507,6 +507,7 @@ const PropertyInfo qdev_prop_uint64_checkmask = {
.type = "uint64",
.get = get_uint64,
.set = set_uint64_checkmask,
+ .set_default_value = qdev_propinfo_set_default_value_uint,
};
/* --- pointer-size integer --- */
diff --git a/include/hw/core/qdev-properties.h b/include/hw/core/qdev-properties.h
index c06de37b1e9d..2ac784bb5e9c 100644
--- a/include/hw/core/qdev-properties.h
+++ b/include/hw/core/qdev-properties.h
@@ -128,14 +128,14 @@ extern const PropertyInfo qdev_prop_link;
##__VA_ARGS__)
/**
- * The DEFINE_PROP_UINT64_CHECKMASK macro checks a user-supplied value
- * against corresponding bitmask, rejects the value if it violates.
- * The default value is set in instance_init().
+ * The DEFINE_PROP_UINT64_CHECKMASK macro checks a value against corresponding
+ * bitmask, rejects the value if it violates.
*/
-#define DEFINE_PROP_UINT64_CHECKMASK(_name, _state, _field, _bitmask) \
- DEFINE_PROP(_name, _state, _field, qdev_prop_uint64_checkmask, uint64_t, \
- .bitmask = (_bitmask), \
- .set_default = false)
+#define DEFINE_PROP_UINT64_CHECKMASK(_name, _state, _field, _bitmask, _defval) \
+ DEFINE_PROP(_name, _state, _field, qdev_prop_uint64_checkmask, uint64_t, \
+ .bitmask = (_bitmask), \
+ .set_default = true, \
+ .defval.u = (_defval))
/**
* DEFINE_PROP_ARRAY:
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index a6d943c53a3f..56735570d66c 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -10265,9 +10265,7 @@ static void x86_cpu_initfn(Object *obj)
object_property_add_alias(obj, "pause_filter", obj, "pause-filter");
object_property_add_alias(obj, "sse4_1", obj, "sse4.1");
object_property_add_alias(obj, "sse4_2", obj, "sse4.2");
-
object_property_add_alias(obj, "hv-apicv", obj, "hv-avic");
- cpu->lbr_fmt = ~PERF_CAP_LBR_FMT;
object_property_add_alias(obj, "lbr_fmt", obj, "lbr-fmt");
if (xcc->model) {
@@ -10439,7 +10437,7 @@ static const Property x86_cpu_properties[] = {
#endif
DEFINE_PROP_INT32("node-id", X86CPU, node_id, CPU_UNSET_NUMA_NODE_ID),
DEFINE_PROP_BOOL("pmu", X86CPU, enable_pmu, false),
- DEFINE_PROP_UINT64_CHECKMASK("lbr-fmt", X86CPU, lbr_fmt, PERF_CAP_LBR_FMT),
+ DEFINE_PROP_UINT64_CHECKMASK("lbr-fmt", X86CPU, lbr_fmt, PERF_CAP_LBR_FMT, 0),
DEFINE_PROP_UINT32("hv-spinlocks", X86CPU, hyperv_spinlock_attempts,
HYPERV_SPINLOCK_NEVER_NOTIFY),
--
2.34.1