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

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