On 2011-05-10 10:02, BrillyWu wrote: > From: BrillyWu <[email protected]> > > When KVM is running on VIA CPU with host cpu's model, the > feautures of VIA CPU will be passed into kvm guest by calling > the CPUID instruction for Centaur. > > Signed-off-by: BrillyWu<[email protected]> > Signed-off-by: KaryJin<[email protected]>
...
> @@ -855,6 +870,8 @@ int cpu_x86_register (CPUX86State *env,
> env->cpuid_xlevel = def->xlevel;
> env->cpuid_kvm_features = def->kvm_features;
> env->cpuid_svm_features = def->svm_features;
> + env->cpuid_ext4_features = def->ext4_features;
> + env->cpuid_xlevel2 = def->xlevel2;
> if (!kvm_enabled()) {
> env->cpuid_features &= TCG_FEATURES;
> env->cpuid_ext_features &= TCG_EXT_FEATURES;
> @@ -1034,7 +1051,12 @@ void cpu_x86_cpuid(CPUX86State *env, uin
> uint32_t *ecx, uint32_t *edx)
> {
> /* test if maximum index reached */
> - if (index & 0x80000000) {
> + if ((index & 0xC000000f) == index) {
This condition can't be correct. It triggers on every index <= 15 and
breaks qemu.
> + /* Handle the Centaur's CPUID instruction. */
> + if (index > env->cpuid_xlevel2) {
> + index = env->cpuid_xlevel2;
> + }
> + } else if (index & 0x80000000) {
Your very first version looked like this:
- if (index & 0x80000000) {
+ if ((index & 0xC0000000) == 0xC0000000) {
+ /* Handle the Centaur's CPUID instruction.*
+ * If cpuid_xlevel2 is "0", then put into the*
+ * default case. */
+ if (env->cpuid_xlevel2 == 0)
+ index = 0xF0000000;
+ else if (index > env->cpuid_xlevel2)
+ index = env->cpuid_xlevel2;
+ } else if (index & 0x80000000) {
Something went wrong here, please re-validate the patch carefully.
Jan
signature.asc
Description: OpenPGP digital signature
