[PATCH v2 19/21] target/i386: remove redundant validation for lbr-fmt property

Zhao Liu posted 21 patches 15 hours ago
Maintainers: Pierrick Bouvier <pierrick.bouvier@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Richard Henderson <richard.henderson@linaro.org>, Zhao Liu <zhao1.liu@intel.com>
[PATCH v2 19/21] target/i386: remove redundant validation for lbr-fmt property
Posted by Zhao Liu 15 hours ago
The 'lbr-fmt' property is defined via DEFINE_PROP_UINT64_CHECKMASK,
utilizing PERF_CAP_LBR_FMT as the validation mask. This mechanism
ensures that the property setter rejects any value attempting to set
bits outside this mask.

So cpu->lbr_fmt is guaranteed to be valid by the time
x86_cpu_realizefn() executes. The manual validation inside the realize
function is therefore redundant.

Remove the unnecessary check.

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
 target/i386/cpu.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index c2f99b98014a..a594747f0030 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -9816,10 +9816,6 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
      * with user-provided setting.
      */
     if (cpu->lbr_fmt != ~PERF_CAP_LBR_FMT) {
-        if ((cpu->lbr_fmt & PERF_CAP_LBR_FMT) != cpu->lbr_fmt) {
-            error_setg(errp, "invalid lbr-fmt");
-            return;
-        }
         env->features[FEAT_PERF_CAPABILITIES] &= ~PERF_CAP_LBR_FMT;
         env->features[FEAT_PERF_CAPABILITIES] |= cpu->lbr_fmt;
     }
-- 
2.34.1