qemu-kvm: remove CPUID host hacks
PATCH 1/1 qemu-kvm: remove CPUID host hacks
KVM provides an in-kernel feature to disable CPUID bits that are not present in the current host. So there is no need here to duplicate this work. Additionally allows 3DNow! on capable processors, since the restriction seems to apply to QEMU/TCG only.
--- target-i386/helper.c | 22 +--------------------- 1 files changed, 1 insertions(+), 21 deletions(-)
This is a rebased version of the qemu.git patch, which caused merge conflicts. Please apply!
Regards,
Andre.
target-i386/helper.c +1 -21
@@ -1645,29 +1645,9 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *edx = env->cpuid_ext2_features;if (kvm_enabled ()) { -uint32_t h_eax, h_edx; - -host_cpuid (index,0 , &h_eax,NULL ,NULL , &h_edx); - -/* disable CPU features that the host does not support */ - -/* long mode */ -if ((h_edx &0x20000000 ) ==0 /* || !lm_capable_kernel */ ) - *edx &= ~0x20000000 ; -/* syscall */ -if ((h_edx &0x00000800 ) ==0 ) - *edx &= ~0x00000800 ; -/* nx */ -if ((h_edx &0x00100000 ) ==0 ) - *edx &= ~0x00100000 ; - -/* disable CPU features that KVM cannot support */ - -/* svm */ +/* disable nested svm if not explicitly requested */ if (!kvm_nested) *ecx &= ~CPUID_EXT3_SVM ; -/* 3dnow */ - *edx &= ~0xc0000000 ; }else {/* AMD 3DNow! is not supported in QEMU */ *edx &= ~(CPUID_EXT2_3DNOW |CPUID_EXT2_3DNOWEXT );
Signature · 1 line
1.6.1.3
Quoted 40 lines · Andre Przywara
KVM provides an in-kernel feature to disable CPUID bits that are not present in the current host. So there is no need here to duplicate this work. Additionally allows 3DNow! on capable processors, since the restriction seems to apply to QEMU/TCG only.
Signed-off-by Andre Przywara <[email protected]>---
target-i386/helper.c| 22 +---------------------1 files changed, 1 insertions(+), 21 deletions(-)This is a rebased version of the qemu.git patch, which caused merge conflicts. Please apply!
Regards,
Andre.target-i386/helper.c +0
-14@@ -1645,29 +1645,9 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_tindex, uint32_t count, *edx = env->cpuid_ext2_features; if (kvm_enabled()) { -uint32_t h_eax, h_edx; - -host_cpuid (index,0 , &h_eax,NULL ,NULL , &h_edx); - -/* disable CPU features that the host does not support */ - -/* long mode */ -if ((h_edx &0x20000000 ) ==0 /* || !lm_capable_kernel */) - *edx &= ~0x20000000 ; -/* syscall */ -if ((h_edx &0x00000800 ) ==0 ) - *edx &= ~0x00000800 ; -/* nx */ -if ((h_edx &0x00100000 ) ==0 )
target-i386/helper.c void cpu_x86_cpuid(CPUX86State *env, uint32_t · line 1672
Quoted 10 lines
target-i386/helper.c +1
-7- *edx &= ~0x00100000 ; - -/* disable CPU features that KVM cannot support */ - -/* svm */ +/* disable nested svm if not explicitly requested */ if (!kvm_nested) *ecx &= ~CPUID_EXT3_SVM ; -/* 3dnow */ - *edx &= ~0xc0000000 ;
I don't know why this is in, but it's definitely in a kvm_enabled() if statement, so it's not because of TCG :-). Also kvm_nested should control the svm bit in the qemu description already. Preferably before the +/-feature bits are interpreted.
... this would lead to total removal of that hack function :-).
Alex