|
|
9ae3a8 |
From 596e3e7f77a1570aff586199e7bb34de0b4e0ba6 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 15 May 2018 11:56:30 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 04/10] target-i386: introduce kvm_put_one_msr
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
9ae3a8 |
Message-id: <20180515115634.24469-2-dgilbert@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 80272
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.6 qemu-kvm PATCH v2 1/5] target-i386: introduce kvm_put_one_msr
|
|
|
9ae3a8 |
Bugzilla: 1577680
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Avoid further code duplication in the next patch.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 73e1b8f2f9b8a90361f9c1af306ee17bfcfd592d)
|
|
|
9ae3a8 |
(cherry picked from commit e9e26236af6a858961280cd4997c437eab27c1e9)
|
|
|
9ae3a8 |
Merge conflict:
|
|
|
9ae3a8 |
We don't yet have Eduardo's patch where kvm_msr_entry_add
|
|
|
9ae3a8 |
was added, so rework to the older kvm_msr_entry_set.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
No msr_feature_control in this world
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
target-i386/kvm.c | 28 +++++++++++++++++++++-------
|
|
|
9ae3a8 |
1 file changed, 21 insertions(+), 7 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
|
|
|
9ae3a8 |
index 24d17ad..6f3424e 100644
|
|
|
9ae3a8 |
--- a/target-i386/kvm.c
|
|
|
9ae3a8 |
+++ b/target-i386/kvm.c
|
|
|
9ae3a8 |
@@ -1136,24 +1136,38 @@ static void kvm_msr_entry_set(struct kvm_msr_entry *entry,
|
|
|
9ae3a8 |
entry->data = value;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-static int kvm_put_tscdeadline_msr(X86CPU *cpu)
|
|
|
9ae3a8 |
+static int kvm_put_one_msr(X86CPU *cpu, int index, uint64_t value)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- CPUX86State *env = &cpu->env;
|
|
|
9ae3a8 |
struct {
|
|
|
9ae3a8 |
struct kvm_msrs info;
|
|
|
9ae3a8 |
struct kvm_msr_entry entries[1];
|
|
|
9ae3a8 |
} msr_data;
|
|
|
9ae3a8 |
- struct kvm_msr_entry *msrs = msr_data.entries;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ kvm_msr_entry_set(&msr_data.entries[0], index, value);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ msr_data.info = (struct kvm_msrs) {
|
|
|
9ae3a8 |
+ .nmsrs = 1,
|
|
|
9ae3a8 |
+ };
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, &msr_data);
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+static int kvm_put_tscdeadline_msr(X86CPU *cpu)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ CPUX86State *env = &cpu->env;
|
|
|
9ae3a8 |
+ int ret;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (!has_msr_tsc_deadline) {
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- kvm_msr_entry_set(&msrs[0], MSR_IA32_TSCDEADLINE, env->tsc_deadline);
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- msr_data.info.nmsrs = 1;
|
|
|
9ae3a8 |
+ ret = kvm_put_one_msr(cpu, MSR_IA32_TSCDEADLINE, env->tsc_deadline);
|
|
|
9ae3a8 |
+ if (ret < 0) {
|
|
|
9ae3a8 |
+ return ret;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, &msr_data);
|
|
|
9ae3a8 |
+ assert(ret == 1);
|
|
|
9ae3a8 |
+ return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static int kvm_put_msrs(X86CPU *cpu, int level)
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|