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

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to