[PATCH v2 06/11] i386/cpu: Allow unsupported avx10_version with x-force-features

Zhao Liu posted 11 patches 2 days, 20 hours ago
[PATCH v2 06/11] i386/cpu: Allow unsupported avx10_version with x-force-features
Posted by Zhao Liu 2 days, 20 hours ago
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 <xudong.hao@intel.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
Changes since v1:
 * New patch.
---
 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 c47e06cb79e7..41ff4058871a 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -9500,16 +9500,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.34.1