提交 8b2fc445 编写于 作者: S Sean Christopherson 提交者: Paolo Bonzini

KVM: x86: Refactor CPUID 0xD.N sub-leaf entry creation

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: NVitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: NSean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 91001d40
...@@ -677,6 +677,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_entry2 *entry, u32 function, ...@@ -677,6 +677,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_entry2 *entry, u32 function,
goto out; goto out;
do_host_cpuid(&entry[i], function, idx); do_host_cpuid(&entry[i], function, idx);
++*nent;
/* /*
* The @supported check above should have filtered out * The @supported check above should have filtered out
...@@ -685,12 +686,13 @@ static inline int __do_cpuid_func(struct kvm_cpuid_entry2 *entry, u32 function, ...@@ -685,12 +686,13 @@ static inline int __do_cpuid_func(struct kvm_cpuid_entry2 *entry, u32 function,
* reach this point, and they should have a non-zero * reach this point, and they should have a non-zero
* save state size. * 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; continue;
}
entry[i].ecx = 0; entry[i].ecx = 0;
entry[i].edx = 0; entry[i].edx = 0;
++*nent;
++i; ++i;
} }
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册