|
 |
c461a1 |
From aa89186992d427e17118608c9fa02b36be8fab8e Mon Sep 17 00:00:00 2001
|
|
 |
c461a1 |
From: "plai@redhat.com" <plai@redhat.com>
|
|
 |
c461a1 |
Date: Mon, 23 Sep 2019 20:40:25 +0200
|
|
 |
c461a1 |
Subject: [PATCH 09/12] kvm: Use KVM_GET_MSR_INDEX_LIST for
|
|
 |
2ec96d |
MSR_IA32_ARCH_CAPABILITIES support
|
|
 |
2ec96d |
|
|
 |
c461a1 |
RH-Author: plai@redhat.com
|
|
 |
c461a1 |
Message-id: <1569271227-28026-9-git-send-email-plai@redhat.com>
|
|
 |
c461a1 |
Patchwork-id: 90861
|
|
 |
c461a1 |
O-Subject: [RHEL7.8 qemu-kvm PATCH v6 08/10] kvm: Use KVM_GET_MSR_INDEX_LIST for MSR_IA32_ARCH_CAPABILITIES support
|
|
 |
c461a1 |
Bugzilla: 1709971
|
|
 |
c461a1 |
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
 |
2ec96d |
RH-Acked-by: Bandan Das <bsd@redhat.com>
|
|
 |
c461a1 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
 |
2ec96d |
|
|
 |
2ec96d |
From: Bandan Das <bsd@redhat.com>
|
|
 |
2ec96d |
|
|
 |
2ec96d |
When writing to guest's MSR_IA32_ARCH_CAPABILITIES, check whether it's
|
|
 |
2ec96d |
supported in the guest using the KVM_GET_MSR_INDEX_LIST ioctl.
|
|
 |
2ec96d |
|
|
 |
2ec96d |
Fixes: d86f963694df27f11b3681ffd225c9362de1b634
|
|
 |
2ec96d |
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
 |
2ec96d |
Tested-by: balducci@units.it
|
|
 |
2ec96d |
Signed-off-by: Bandan Das <bsd@redhat.com>
|
|
 |
2ec96d |
Message-Id: <jpg4lc4iiav.fsf_-_@linux.bootlegged.copy>
|
|
 |
2ec96d |
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
 |
2ec96d |
(cherry picked from commit aec5e9c3a94cf8b7920f59bef69a6f426092c4a0)
|
|
 |
2ec96d |
Signed-off-by: Paul Lai <plai@redhat.com>
|
|
 |
c461a1 |
|
|
 |
c461a1 |
Resolved Conflicts:
|
|
 |
c461a1 |
target/i386/kvm.c changes to target-i386/kvm.c
|
|
 |
c461a1 |
|
|
 |
2ec96d |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
 |
2ec96d |
---
|
|
 |
2ec96d |
target-i386/cpu.h | 1 +
|
|
 |
2ec96d |
target-i386/kvm.c | 19 +++++++++++--------
|
|
 |
2ec96d |
2 files changed, 12 insertions(+), 8 deletions(-)
|
|
 |
2ec96d |
|
|
 |
2ec96d |
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
|
|
 |
c461a1 |
index 5a86b2c..8f73af7 100644
|
|
 |
2ec96d |
--- a/target-i386/cpu.h
|
|
 |
2ec96d |
+++ b/target-i386/cpu.h
|
|
 |
c461a1 |
@@ -1070,6 +1070,7 @@ typedef struct CPUX86State {
|
|
 |
2ec96d |
|
|
 |
2ec96d |
uint64_t spec_ctrl;
|
|
 |
2ec96d |
uint64_t virt_ssbd;
|
|
 |
2ec96d |
+ uint64_t virt_arch_capabs;
|
|
 |
2ec96d |
|
|
 |
2ec96d |
TPRAccess tpr_access_type;
|
|
 |
2ec96d |
} CPUX86State;
|
|
 |
2ec96d |
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
|
|
 |
c461a1 |
index 722cfbc..12781a8 100644
|
|
 |
2ec96d |
--- a/target-i386/kvm.c
|
|
 |
2ec96d |
+++ b/target-i386/kvm.c
|
|
 |
c461a1 |
@@ -81,6 +81,7 @@ static bool has_msr_mtrr;
|
|
 |
2ec96d |
static bool has_msr_xss;
|
|
 |
2ec96d |
static bool has_msr_spec_ctrl;
|
|
 |
2ec96d |
static bool has_msr_virt_ssbd;
|
|
 |
2ec96d |
+static bool has_msr_arch_capabs;
|
|
 |
2ec96d |
|
|
 |
2ec96d |
static bool has_msr_architectural_pmu;
|
|
 |
2ec96d |
static uint32_t num_architectural_pmu_counters;
|
|
 |
c461a1 |
@@ -902,6 +903,10 @@ static int kvm_get_supported_msrs(KVMState *s)
|
|
 |
2ec96d |
has_msr_virt_ssbd = true;
|
|
 |
2ec96d |
continue;
|
|
 |
2ec96d |
}
|
|
 |
2ec96d |
+ if (kvm_msr_list->indices[i] == MSR_IA32_ARCH_CAPABILITIES) {
|
|
 |
2ec96d |
+ has_msr_arch_capabs = true;
|
|
 |
2ec96d |
+ continue;
|
|
 |
2ec96d |
+ }
|
|
 |
2ec96d |
}
|
|
 |
2ec96d |
}
|
|
 |
2ec96d |
|
|
 |
c461a1 |
@@ -1340,14 +1345,9 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
|
|
 |
2ec96d |
}
|
|
 |
2ec96d |
}
|
|
 |
2ec96d |
/* If host supports feature MSR, write down. */
|
|
 |
2ec96d |
- if (kvm_feature_msrs) {
|
|
 |
2ec96d |
- int i;
|
|
 |
2ec96d |
- for (i = 0; i < kvm_feature_msrs->nmsrs; i++)
|
|
 |
2ec96d |
- if (kvm_feature_msrs->indices[i] == MSR_IA32_ARCH_CAPABILITIES) {
|
|
 |
2ec96d |
- kvm_msr_entry_set(&msrs[n++], MSR_IA32_ARCH_CAPABILITIES,
|
|
 |
2ec96d |
- env->features[FEAT_ARCH_CAPABILITIES]);
|
|
 |
2ec96d |
- break;
|
|
 |
2ec96d |
- }
|
|
 |
2ec96d |
+ if (has_msr_arch_capabs) {
|
|
 |
2ec96d |
+ kvm_msr_entry_set(&msrs[n++], MSR_IA32_ARCH_CAPABILITIES,
|
|
 |
2ec96d |
+ env->features[FEAT_ARCH_CAPABILITIES]);
|
|
 |
2ec96d |
}
|
|
 |
2ec96d |
/*
|
|
 |
2ec96d |
* The following MSRs have side effects on the guest or are too heavy
|
|
 |
c461a1 |
@@ -1939,6 +1939,9 @@ static int kvm_get_msrs(X86CPU *cpu)
|
|
 |
2ec96d |
case MSR_VIRT_SSBD:
|
|
 |
2ec96d |
env->virt_ssbd = msrs[i].data;
|
|
 |
2ec96d |
break;
|
|
 |
2ec96d |
+ case MSR_IA32_ARCH_CAPABILITIES:
|
|
 |
2ec96d |
+ env->features[FEAT_ARCH_CAPABILITIES] = msrs[i].data;
|
|
 |
2ec96d |
+ break;
|
|
 |
2ec96d |
}
|
|
 |
2ec96d |
}
|
|
 |
2ec96d |
|
|
 |
2ec96d |
--
|
|
 |
2ec96d |
1.8.3.1
|
|
 |
2ec96d |
|