[PATCH] target/i386/cpu: Add back x-hv-synic-kvm-only property

Paolo Bonzini posted 1 patch 1 day, 12 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261126125325.2223204-1-pbonzini@redhat.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Zhao Liu <zhao1.liu@intel.com>, Marcelo Tosatti <mtosatti@redhat.com>
target/i386/cpu.h     |  1 +
target/i386/cpu.c     |  2 ++
target/i386/kvm/kvm.c | 15 +++++++++------
3 files changed, 12 insertions(+), 6 deletions(-)
[PATCH] target/i386/cpu: Add back x-hv-synic-kvm-only property
Posted by Paolo Bonzini 1 day, 12 hours ago
Partially revert commit 804cca26dc9 ("target/i386/kvm: Remove
X86CPU::hyperv_synic_kvm_only field").  The option was removed because it
was only enabled by old machine types, but it can be useful for debugging
as well.

Do not bring back usage of KVM_CAP_HYPERV_SYNIC, which only differs from
KVM_CAP_HYPERV_SYNIC2 in that the latter signals that some bugs were
fixed in KVM; and keep the hv-vpindex requirement even with the option
on, since in-kernel SynIC wants the feature to be active anyway.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/cpu.h     |  1 +
 target/i386/cpu.c     |  2 ++
 target/i386/kvm/kvm.c | 15 +++++++++------
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 3945e90371b..0ceb4be7413 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -2373,6 +2373,7 @@ struct ArchCPU {
 
     uint32_t hyperv_spinlock_attempts;
     char *hyperv_vendor;
+    bool hyperv_synic_kvm_only;
     uint64_t hyperv_features;
     bool hyperv_passthrough;
     OnOffAuto hyperv_no_nonarch_cs;
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 40974bee26c..14d7b86ad0f 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -10900,6 +10900,8 @@ static const Property x86_cpu_properties[] = {
      * to the specific Windows version being used."
      */
     DEFINE_PROP_INT32("x-hv-max-vps", X86CPU, hv_max_vps, -1),
+    DEFINE_PROP_BOOL("x-hv-synic-kvm-only", X86CPU, hyperv_synic_kvm_only,
+                     false),
     DEFINE_PROP_BOOL("x-l1-cache-per-thread", X86CPU, l1_cache_per_core, true),
     DEFINE_PROP_BOOL("x-force-cpuid-0x1f", X86CPU, force_cpuid_0x1f, false),
 
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 76528f1123f..bc5a39cecf4 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -1607,7 +1607,8 @@ static int hyperv_fill_cpuids(CPUState *cs,
     c->eax |= HV_HYPERCALL_AVAILABLE;
 
     /* SynIC and Vmbus devices require messages/signals hypercalls */
-    if (hyperv_feat_enabled(cpu, HYPERV_FEAT_SYNIC)) {
+    if (hyperv_feat_enabled(cpu, HYPERV_FEAT_SYNIC) &&
+        !cpu->hyperv_synic_kvm_only) {
         c->ebx |= HV_POST_MESSAGES | HV_SIGNAL_EVENTS;
     }
 
@@ -1757,11 +1758,13 @@ static int hyperv_init_vcpu(X86CPU *cpu)
             return ret;
         }
 
-        ret = hyperv_enable_synic(cpu);
-        if (ret < 0) {
-            error_report("failed to create HyperV SynIC: %s",
-                         strerror(-ret));
-            return ret;
+        if (!cpu->hyperv_synic_kvm_only) {
+            ret = hyperv_enable_synic(cpu);
+            if (ret < 0) {
+                error_report("failed to create HyperV SynIC: %s",
+                             strerror(-ret));
+                return ret;
+            }
         }
     }
 
-- 
2.56.1