qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Yang, Weijiang" <weijiang.yang@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	ehabkost@redhat.com, qemu-devel@nongnu.org
Subject: Re: [PATCH] target/i386: Add kvm_get_one_msr helper
Date: Fri, 28 Jan 2022 23:09:38 +0800	[thread overview]
Message-ID: <eac439e3-782f-ac05-c9ff-a45cea720d4c@intel.com> (raw)
In-Reply-To: <932291d0-954b-7092-b61d-83182413ba9d@redhat.com>


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	other threads:[~2022-01-28 15:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-27 15:58 [PATCH] target/i386: Add kvm_get_one_msr helper Yang Weijiang
2022-01-28 10:55 ` Paolo Bonzini
2022-01-28 15:09   ` Yang, Weijiang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eac439e3-782f-ac05-c9ff-a45cea720d4c@intel.com \
    --to=weijiang.yang@intel.com \
    --cc=ehabkost@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).