From: "Chen, Zide" <zide.chen@intel.com>
To: "Zhao Liu" <zhao1.liu@intel.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Daniel P . Berrangé" <berrange@redhat.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Markus Armbruster" <armbru@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Igor Mammedov" <imammedo@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: Richard Henderson <richard.henderson@linaro.org>,
Peter Maydell <peter.maydell@linaro.org>,
"Michael S . Tsirkin" <mst@redhat.com>,
BALATON Zoltan <balaton@eik.bme.hu>,
Mark Cave-Ayland <mark.caveayland@nutanix.com>,
Pierrick Bouvier <pierrick.bouvier@linaro.org>,
Dapeng Mi <dapeng1.mi@linux.intel.com>,
qemu-devel@nongnu.org, devel@lists.libvirt.org
Subject: Re: [PATCH v2 21/21] hw/core/qdev-properties: support valid default value for DEFINE_PROP_UINT64_CHECKMASK
Date: Fri, 13 Mar 2026 15:36:12 -0700 [thread overview]
Message-ID: <a4df97c1-ca68-490c-8576-dc83a1908da9@intel.com> (raw)
In-Reply-To: <20260210032348.987549-22-zhao1.liu@intel.com>
On 2/9/2026 7:23 PM, Zhao Liu wrote:
> 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>
> ---
Nice to see "cpu->lbr_fmt = ~PERF_CAP_LBR_FMT" is gone.
Reviewed-by: Zide Chen <zide.chen@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),
next prev parent reply other threads:[~2026-03-13 22:36 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-10 3:23 [PATCH v2 00/21] qom: introduce property flags to track external user input Zhao Liu
2026-02-10 3:23 ` [PATCH v2 01/21] qom/object: use BIT macro for ObjectPropertyFlags Zhao Liu
2026-03-20 9:53 ` Thomas Huth
2026-02-10 3:23 ` [PATCH v2 02/21] qom/object: cache ObjectPropertyFlags in ObjectProperty Zhao Liu
2026-03-20 9:53 ` Thomas Huth
2026-02-10 3:23 ` [PATCH v2 03/21] qom/object: factor out object_class_property_try_add() Zhao Liu
2026-02-10 14:41 ` BALATON Zoltan
2026-02-11 7:14 ` Zhao Liu
2026-02-10 3:23 ` [PATCH v2 04/21] qom/object: add flags argument in object_{class_}property_try_add() Zhao Liu
2026-02-10 3:23 ` [PATCH v2 05/21] qom/object: rename object_{class_}property_try_add() to object_{class_}property_add_full() Zhao Liu
2026-02-10 3:23 ` [PATCH v2 06/21] qom/object: add helpers to set/get/clear property flags Zhao Liu
2026-02-10 3:23 ` [PATCH v2 07/21] qom/object: introduce user interaction flags for properties Zhao Liu
2026-02-10 9:49 ` Daniel P. Berrangé
2026-02-10 9:58 ` Daniel P. Berrangé
2026-02-11 8:19 ` Zhao Liu
2026-02-10 14:44 ` BALATON Zoltan
2026-02-11 7:22 ` Zhao Liu
2026-02-10 3:23 ` [PATCH v2 08/21] qom/object: add from_user argument in object_property_parse() Zhao Liu
2026-02-10 3:23 ` [PATCH v2 09/21] qom/object: mark global property set from CLI as USER_SET Zhao Liu
2026-02-10 3:23 ` [PATCH v2 10/21] qom/qom-hmp-cmd: mark properties set from HMP (non-JSON) "qom-set" " Zhao Liu
2026-02-10 3:23 ` [PATCH v2 11/21] qom/qom-qmp-cmd: mark properties set from QMP/HMP (JSON) " Zhao Liu
2026-02-10 3:23 ` [PATCH v2 12/21] qom/object_interfaces: mark properties set from qdict & keyval " Zhao Liu
2026-02-10 3:23 ` [PATCH v2 13/21] system/vl: mark property set in object_parse_property_opt() " Zhao Liu
2026-02-10 3:23 ` [PATCH v2 14/21] hw/core/qdev-properties: allow qdev properties accept flags Zhao Liu
2026-02-10 9:41 ` Peter Krempa
2026-02-11 7:10 ` Zhao Liu
2026-02-10 9:56 ` Daniel P. Berrangé
2026-02-11 7:30 ` Zhao Liu
2026-02-11 16:58 ` Daniel P. Berrangé
2026-02-12 15:25 ` Zhao Liu
2026-02-12 15:42 ` Daniel P. Berrangé
2026-03-09 13:34 ` Zhao Liu
2026-02-18 9:51 ` Igor Mammedov
2026-03-06 9:14 ` Markus Armbruster
2026-03-06 9:19 ` Daniel P. Berrangé
2026-03-06 9:30 ` Markus Armbruster
2026-03-09 13:52 ` Zhao Liu
2026-02-10 3:23 ` [PATCH v2 15/21] target/i386: deprecate fill-mtrr-mask property Zhao Liu
2026-02-10 3:23 ` [PATCH v2 16/21] target/i386: deprecate cpuid-0xb property Zhao Liu
2026-02-10 3:23 ` [PATCH v2 17/21] hw/intc/ioapic: deprecate version property Zhao Liu
2026-02-10 3:23 ` [PATCH v2 18/21] target/i386: mark x-consistent-cache property as internal-only Zhao Liu
2026-02-10 3:23 ` [PATCH v2 19/21] target/i386: remove redundant validation for lbr-fmt property Zhao Liu
2026-03-13 22:34 ` Chen, Zide
2026-02-10 3:23 ` [PATCH v2 20/21] target/i386: detect user provided lbr-fmt via property flag Zhao Liu
2026-03-13 22:36 ` Chen, Zide
2026-02-10 3:23 ` [PATCH v2 21/21] hw/core/qdev-properties: support valid default value for DEFINE_PROP_UINT64_CHECKMASK Zhao Liu
2026-03-13 22:36 ` Chen, Zide [this message]
2026-02-10 10:12 ` [PATCH v2 00/21] qom: introduce property flags to track external user input Daniel P. Berrangé
2026-02-10 10:44 ` Michael S. Tsirkin
2026-02-10 11:00 ` Daniel P. Berrangé
2026-02-10 15:00 ` BALATON Zoltan
2026-02-10 15:28 ` Zhao Liu
2026-02-10 15:16 ` BALATON Zoltan
2026-02-11 7:24 ` Zhao Liu
2026-02-11 11:28 ` BALATON Zoltan
2026-02-12 15:31 ` Zhao Liu
2026-02-12 15:56 ` BALATON Zoltan
2026-02-10 15:41 ` Daniel P. Berrangé
2026-02-11 7:06 ` Zhao Liu
2026-02-11 11:18 ` Daniel P. Berrangé
2026-03-11 13:05 ` Markus Armbruster
2026-03-11 13:14 ` Daniel P. Berrangé
2026-03-11 13:38 ` Peter Krempa
2026-03-16 15:43 ` Markus Armbruster
2026-03-16 16:05 ` BALATON Zoltan
2026-03-16 18:00 ` Markus Armbruster
2026-03-20 10:09 ` Daniel P. Berrangé
2026-03-23 15:37 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a4df97c1-ca68-490c-8576-dc83a1908da9@intel.com \
--to=zide.chen@intel.com \
--cc=armbru@redhat.com \
--cc=balaton@eik.bme.hu \
--cc=berrange@redhat.com \
--cc=dapeng1.mi@linux.intel.com \
--cc=devel@lists.libvirt.org \
--cc=eduardo@habkost.net \
--cc=imammedo@redhat.com \
--cc=mark.caveayland@nutanix.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
--cc=zhao1.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.