From nobody Tue Feb 10 19:23:02 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1770692428; cv=none; d=zohomail.com; s=zohoarc; b=gEv74zh3mMxSOdjqf5nobK2PfVu1oP79mppuWWToQFFlklreoNLVdb4KM4z8T2sklYXZWxMbg3YpxqqWJxDx1QKssnT/xMiMj7jwwDLA30c/Yw3mQDQqqMZ2OxkS9JV0u4zL+PzSDeGTK9I6ZgxnnTl9z0GyTZoGS3ytbWBUj3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770692428; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TOFv4IfsHfkgUKtIDD6/Wik0wXdVpIKi0wusTKArM5U=; b=fC7DOCYrg2YSlI+cqBP3ELE2lThIIMkUsnnnw77EuQkp84wpDKnlqeDkWMGdsdkiUgJbzBBFI6swizBfVg5+F6QGh9KJtlrWIZlF9JpxJD5hMDD9ZytcdEvSXRJiepSZHUwUsFDPzUudcwY3O8BobMLq6STdaMmsAK3nLQOovFk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1770692428694328.0117719945865; Mon, 9 Feb 2026 19:00:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vpdz8-0001m9-FZ; Mon, 09 Feb 2026 22:00:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vpdyp-0001FT-2m for qemu-devel@nongnu.org; Mon, 09 Feb 2026 22:00:04 -0500 Received: from mgamail.intel.com ([198.175.65.14]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vpdyj-0004En-8w for qemu-devel@nongnu.org; Mon, 09 Feb 2026 21:59:56 -0500 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2026 18:59:52 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa008.jf.intel.com with ESMTP; 09 Feb 2026 18:59:48 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1770692393; x=1802228393; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k4278D/unK5bwhnrNdxt3ByvRIvl2uTcZ+7sAYt5EQ8=; b=FTCQRrhlGPaeb6EDicFIoNZ8bnxUx1Hzm6NT1O5Vzf9+lLZ37evmDVss E0N3htA0YzNNNCiHcCtCaaZSi2NeVaje96Xmutp7/YD67AO3B0ejICUUA XhMF3YjfQHdiS+ffqG5EM1Zp9poS5+kaKJGGVdeM3fQS9je8GYzvQR+7o fW+gt8XnZWnPgmFMdjKG1bxeAWRC5m143VD7FpfvV61fMGGfMz3R3ezEf VtPAhmajQrYmLUXoPhXmAx2rhOy4JQJT0j2Gm0jP2oVJZCTzNbBnfECGN jCKGk8evC1UdgXutgYTu4gkWr8xasd7A+hhmdQ7X1JFmid4E07PjQWGX2 Q==; X-CSE-ConnectionGUID: LhZvm5wETU6soCoDWHn4aQ== X-CSE-MsgGUID: YuQwNruzQ2C4TA/xXjl/IA== X-IronPort-AV: E=McAfee;i="6800,10657,11696"; a="75660026" X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="75660026" X-CSE-ConnectionGUID: R1aMdRTGRnSweM0ElxSd+Q== X-CSE-MsgGUID: rOuhMUKASpSp2/7FEzorpg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="211800818" From: Zhao Liu To: Paolo Bonzini , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Eduardo Habkost , Markus Armbruster , Thomas Huth , Igor Mammedov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Cc: Richard Henderson , Peter Maydell , "Michael S . Tsirkin" , BALATON Zoltan , Mark Cave-Ayland , Pierrick Bouvier , Zide Chen , Dapeng Mi , Zhao Liu , qemu-devel@nongnu.org, devel@lists.libvirt.org Subject: [PATCH v2 21/21] hw/core/qdev-properties: support valid default value for DEFINE_PROP_UINT64_CHECKMASK Date: Tue, 10 Feb 2026 11:23:48 +0800 Message-Id: <20260210032348.987549-22-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260210032348.987549-1-zhao1.liu@intel.com> References: <20260210032348.987549-1-zhao1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.14; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1770692429507158500 Content-Type: text/plain; charset="utf-8" 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 --- 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 =3D { .type =3D "uint64", .get =3D get_uint64, .set =3D set_uint64_checkmask, + .set_default_value =3D qdev_propinfo_set_default_value_uint, }; =20 /* --- pointer-size integer --- */ diff --git a/include/hw/core/qdev-properties.h b/include/hw/core/qdev-prope= rties.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__) =20 /** - * 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 correspon= ding + * 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 =3D (_bitmask), \ - .set_default =3D false) +#define DEFINE_PROP_UINT64_CHECKMASK(_name, _state, _field, _bitmask, _def= val) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_uint64_checkmask, uint64_= t, \ + .bitmask =3D (_bitmask), = \ + .set_default =3D true, = \ + .defval.u =3D (_defval)) =20 /** * 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 =3D ~PERF_CAP_LBR_FMT; object_property_add_alias(obj, "lbr_fmt", obj, "lbr-fmt"); =20 if (xcc->model) { @@ -10439,7 +10437,7 @@ static const Property x86_cpu_properties[] =3D { #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), =20 DEFINE_PROP_UINT32("hv-spinlocks", X86CPU, hyperv_spinlock_attempts, HYPERV_SPINLOCK_NEVER_NOTIFY), --=20 2.34.1