Increment the number of CPUID entries immediately after do_host_cpuid()
in preparation for moving the logic into do_host_cpuid(). Handle the
rare/impossible case of encountering a bogus sub-leaf by decrementing
the number entries on failure.
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
goto out;
do_host_cpuid(&entry[i], function, idx);
+ ++*nent;
/*
* The @supported check above should have filtered out
* reach this point, and they should have a non-zero
* save state size.
*/
- if (WARN_ON_ONCE(!entry[i].eax || (entry[i].ecx & 1)))
+ if (WARN_ON_ONCE(!entry[i].eax || (entry[i].ecx & 1))) {
+ --*nent;
continue;
+ }
entry[i].ecx = 0;
entry[i].edx = 0;
- ++*nent;
++i;
}
break;