KVM has quirks to overcome legacy QEMU bugs that are already resolved.  Using a
new KVM feature for disabling these quirks.

Signed-off-by: Nadav Amit <na...@cs.technion.ac.il>
---
 linux-headers/asm-x86/kvm.h | 4 ++++
 linux-headers/linux/kvm.h   | 1 +
 target-i386/kvm.c           | 8 ++++++++
 3 files changed, 13 insertions(+)

diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h
index d7dcef5..f8fbb4a 100644
--- a/linux-headers/asm-x86/kvm.h
+++ b/linux-headers/asm-x86/kvm.h
@@ -345,4 +345,8 @@ struct kvm_xcrs {
 struct kvm_sync_regs {
 };
 
+/* KVM legacy quirks for use with KVM_CAP_DISABLE_QUIRKS */
+#define KVM_QUIRK_LINT0_DISABLED       (1 << 0)
+#define KVM_QUIRK_CD_NW_CLEARED                (1 << 1)
+
 #endif /* _ASM_X86_KVM_H */
diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index 60a54c8..757e869 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -760,6 +760,7 @@ struct kvm_ppc_smmu_info {
 #define KVM_CAP_PPC_ENABLE_HCALL 104
 #define KVM_CAP_CHECK_EXTENSION_VM 105
 #define KVM_CAP_S390_USER_SIGP 106
+#define KVM_CAP_DISABLE_QUIRKS 115
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 41d09e5..3b28122 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -898,6 +898,14 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
             return ret;
         }
     }
+    if (kvm_check_extension(s, KVM_CAP_ENABLE_CAP_VM)) {
+        ret = kvm_vm_enable_cap(s, KVM_CAP_DISABLE_QUIRKS, 0,
+                                KVM_QUIRK_LINT0_DISABLED |
+                                KVM_QUIRK_CD_NW_CLEARED);
+        if (ret < 0) {
+            return ret;
+        }
+    }
     return 0;
 }
 
-- 
1.9.1


Reply via email to