From: Paolo Bonzini <pbonzini@redhat.com>
To: Yang Weijiang <weijiang.yang@intel.com>,
ehabkost@redhat.com, qemu-devel@nongnu.org
Subject: Re: [PATCH] target/i386: Add kvm_get_one_msr helper
Date: Fri, 28 Jan 2022 11:55:02 +0100 [thread overview]
Message-ID: <932291d0-954b-7092-b61d-83182413ba9d@redhat.com> (raw)
In-Reply-To: <20220127155845.95594-1-weijiang.yang@intel.com>
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
next prev parent reply other threads:[~2022-01-28 10:57 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 [this message]
2022-01-28 15:09 ` Yang, Weijiang
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=932291d0-954b-7092-b61d-83182413ba9d@redhat.com \
--to=pbonzini@redhat.com \
--cc=ehabkost@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=weijiang.yang@intel.com \
/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).