qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] target/i386: Add kvm_get_one_msr helper


From: Yang, Weijiang
Subject: Re: [PATCH] target/i386: Add kvm_get_one_msr helper
Date: Fri, 28 Jan 2022 23:09:38 +0800
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0


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

[Prev in Thread] Current Thread [Next in Thread]