yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-target-i386-work-around-KVM_GET_MSRS-bug-for-seconda.patch

016a62
From 92fad7ff756d40b231399a1eeedb7caca9ab321e Mon Sep 17 00:00:00 2001
016a62
From: Paolo Bonzini <pbonzini@redhat.com>
016a62
Date: Fri, 22 Nov 2019 11:53:45 +0000
016a62
Subject: [PATCH 12/16] target/i386: work around KVM_GET_MSRS bug for secondary
016a62
 execution controls
016a62
016a62
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
016a62
Message-id: <20191122115348.25000-13-pbonzini@redhat.com>
016a62
Patchwork-id: 92609
016a62
O-Subject: [RHEL8.2/rhel qemu-kvm PATCH 12/15] target/i386: work around KVM_GET_MSRS bug for secondary execution controls
016a62
Bugzilla: 1689270
016a62
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
016a62
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
016a62
RH-Acked-by: Maxim Levitsky <mlevitsk@redhat.com>
016a62
016a62
Some secondary controls are automatically enabled/disabled based on the CPUID
016a62
values that are set for the guest.  However, they are still available at a
016a62
global level and therefore should be present when KVM_GET_MSRS is sent to
016a62
/dev/kvm.
016a62
016a62
Unfortunately KVM forgot to include those, so fix that.
016a62
016a62
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
016a62
(cherry picked from commit 048c95163b472ed737a2f0dca4f4e23a82ac2f8a)
016a62
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
016a62
---
016a62
 target/i386/kvm.c | 17 +++++++++++++++++
016a62
 1 file changed, 17 insertions(+)
016a62
016a62
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
016a62
index 512d7d5..6366172 100644
016a62
--- a/target/i386/kvm.c
016a62
+++ b/target/i386/kvm.c
016a62
@@ -460,6 +460,23 @@ uint64_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index)
016a62
     value = msr_data.entries[0].data;
016a62
     switch (index) {
016a62
     case MSR_IA32_VMX_PROCBASED_CTLS2:
016a62
+        /* KVM forgot to add these bits for some time, do this ourselves.  */
016a62
+        if (kvm_arch_get_supported_cpuid(s, 0xD, 1, R_ECX) & CPUID_XSAVE_XSAVES) {
016a62
+            value |= (uint64_t)VMX_SECONDARY_EXEC_XSAVES << 32;
016a62
+        }
016a62
+        if (kvm_arch_get_supported_cpuid(s, 1, 0, R_ECX) & CPUID_EXT_RDRAND) {
016a62
+            value |= (uint64_t)VMX_SECONDARY_EXEC_RDRAND_EXITING << 32;
016a62
+        }
016a62
+        if (kvm_arch_get_supported_cpuid(s, 7, 0, R_EBX) & CPUID_7_0_EBX_INVPCID) {
016a62
+            value |= (uint64_t)VMX_SECONDARY_EXEC_ENABLE_INVPCID << 32;
016a62
+        }
016a62
+        if (kvm_arch_get_supported_cpuid(s, 7, 0, R_EBX) & CPUID_7_0_EBX_RDSEED) {
016a62
+            value |= (uint64_t)VMX_SECONDARY_EXEC_RDSEED_EXITING << 32;
016a62
+        }
016a62
+        if (kvm_arch_get_supported_cpuid(s, 0x80000001, 0, R_EDX) & CPUID_EXT2_RDTSCP) {
016a62
+            value |= (uint64_t)VMX_SECONDARY_EXEC_RDTSCP << 32;
016a62
+        }
016a62
+        /* fall through */
016a62
     case MSR_IA32_VMX_TRUE_PINBASED_CTLS:
016a62
     case MSR_IA32_VMX_TRUE_PROCBASED_CTLS:
016a62
     case MSR_IA32_VMX_TRUE_ENTRY_CTLS:
016a62
-- 
016a62
1.8.3.1
016a62