cryptospore / rpms / qemu-kvm

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