From: Avi Kivity <avi@redhat.com>
To: Sasha Levin <levinsasha928@gmail.com>
Cc: kvm@vger.kernel.org, Marcelo Tosatti <mtosatti@redhat.com>
Subject: Re: [PATCH v2] KVM: Refactor and simplify kvm_dev_ioctl_get_supported_cpuid
Date: Mon, 28 Nov 2011 11:52:30 +0200 [thread overview]
Message-ID: <4ED359DE.6060005@redhat.com> (raw)
In-Reply-To: <1322472029-22856-1-git-send-email-levinsasha928@gmail.com>
On 11/28/2011 11:20 AM, Sasha Levin wrote:
> This patch cleans and simplifies kvm_dev_ioctl_get_supported_cpuid by using a table
> instead of duplicating code as Avi suggested.
>
> This patch also fixes a bug where kvm_dev_ioctl_get_supported_cpuid would return
> -E2BIG when amount of entries passed was just right.
>
> do_cpuid_1_ent(entry, function, index);
> ++*nent;
>
> @@ -275,7 +282,10 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
>
> entry->flags |= KVM_CPUID_FLAG_STATEFUL_FUNC;
> entry->flags |= KVM_CPUID_FLAG_STATE_READ_NEXT;
> - for (t = 1; t < times && *nent < maxnent; ++t) {
> + for (t = 1; t < times; ++t) {
> + if (*nent >= maxnent)
> + goto out;
> +
> do_cpuid_1_ent(&entry[t], function, 0);
> entry[t].flags |= KVM_CPUID_FLAG_STATEFUL_FUNC;
> ++*nent;
Please move the check into do_cpuid_1_ent(); it's more consistent.
> @@ -296,6 +309,7 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
> entry[i].flags |=
> KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
> ++*nent;
> +
> }
> break;
Spurious?
> }
> @@ -335,7 +352,10 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
> int idx, i;
>
> entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
> - for (idx = 1, i = 1; *nent < maxnent && idx < 64; ++idx) {
> + for (idx = 1, i = 1; idx < 64; ++idx) {
> + if (*nent >= maxnent)
> + goto out;
> +
> do_cpuid_1_ent(&entry[i], function, idx);
> if (entry[i].eax == 0 || !supported_xcr0_bit(idx))
> continue;
This would go away too then.
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2011-11-28 9:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-28 9:20 [PATCH v2] KVM: Refactor and simplify kvm_dev_ioctl_get_supported_cpuid Sasha Levin
2011-11-28 9:52 ` Avi Kivity [this message]
2011-11-28 10:08 ` Avi Kivity
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=4ED359DE.6060005@redhat.com \
--to=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=levinsasha928@gmail.com \
--cc=mtosatti@redhat.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).