From: Zhao Liu <[email protected]>

The "force_features" ("x-force-features" property) forces setting
feature even if host doesn't support, but also reports the warning.

Given its function, it's useful for debug, so even if the AVX10
version is unsupported by host, force to set this AVX10 version if
x-force-features=on.

Tested-by: Xudong Hao <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
---
 target/i386/cpu.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index c460e3bec7c..f62bd48d4b0 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -9490,16 +9490,27 @@ static bool x86_cpu_filter_features(X86CPU *cpu, bool 
verbose)
         uint8_t version = x86_cpu_get_host_avx10_version();
 
         if (version < env->avx10_version) {
-            if (prefix) {
-                warn_report("%s: avx10.%d. Adjust to avx10.%d",
-                            prefix, env->avx10_version, version);
-            }
             /*
-             * Discrete feature bits have been checked and filtered based on
-             * host support. So it's safe to change version without reverting
-             * other feature bits.
+             * With x-force-features=on, CPUID_7_1_EDX_AVX10 will not be masked
+             * off, so there's no need to zero avx10 version.
              */
-            env->avx10_version = version;
+            if (!cpu->force_features) {
+                if (prefix) {
+                    warn_report("%s: avx10.%d. Adjust to avx10.%d",
+                                prefix, env->avx10_version, version);
+                }
+                /*
+                 * Discrete feature bits have been checked and filtered based
+                 * on host support. So it's safe to change version without
+                 * reverting other feature bits.
+                 */
+                env->avx10_version = version;
+            } else {
+                if (prefix) {
+                    warn_report("%s: avx10.%d.",
+                                prefix, env->avx10_version);
+                }
+            }
             have_filtered_features = true;
         }
     } else if (env->avx10_version) {
-- 
2.52.0


Reply via email to