On 1/28/2022 6:55 PM, Paolo Bonzini wrote:
On 1/27/22 16:58, Yang Weijiang wrote:
@@ -135,6 +135,7 @@ static struct kvm_msr_list *kvm_feature_msrs;
    #define BUS_LOCK_SLICE_TIME 1000000000ULL /* ns */
  static RateLimit bus_lock_ratelimit_ctrl;
+static int kvm_get_one_msr(X86CPU *cpu, int index, uint64_t *value);
    int kvm_has_pit_state2(void)
  {

...

@@ -2734,6 +2721,25 @@ static int kvm_put_one_msr(X86CPU *cpu, int index, uint64_t value)
      return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, cpu->kvm_msr_buf);
  }
  +static int kvm_get_one_msr(X86CPU *cpu, int index, uint64_t *value)
+{
+    int ret;
+    struct {
+        struct kvm_msrs info;
+        struct kvm_msr_entry entries[1];
+    } msr_data = {
+        .info.nmsrs = 1,
+        .entries[0].index = index,
+    };
+
+    ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_MSRS, &msr_data);
+    if (ret < 0) {
+        return ret;
+    }
+    assert(ret == 1);
+    *value = msr_data.entries[0].data;
+    return ret;
+}
  void kvm_put_apicbase(X86CPU *cpu, uint64_t value)
  {
      int ret;

The patch is a good idea, but you can put the function before the uses.  This way there will be no need for a forward declaration, either.

Thanks Paolo!

Is v2 version required for this?


Thanks,

Paolo

Reply via email to