2008/11/23

KVM virtualization fix on Gentoo 2008.0 stable version

A recent kvm / kernel update breaks kvm virtualization on my gentoo 2008.0 stable version machine.
The situation is similar to this guy:
http://www.mail-archive.com/kvm@vger.kernel.org/msg06167.html
There is a bug in 2.6.25 kernel about HLT instruction which doesn't work well under newer kvm code, which is fixed in 2.6.26.1, but gentoo's kernel is just too old for that, after a week of search, I found the solution is just a line of code change.
--- a/arch/x86/kvm/x86_emulate.c
+++ b/arch/x86/kvm/x86_emulate.c
@@ -1666,7 +1666,7 @@ special_insn:
break;
case 0xf4: /* hlt */
ctxt->vcpu->arch.halt_request = 1;
- goto done;
+ break;
case 0xf5: /* cmc */
/* complement carry flag from eflags reg */
ctxt->eflags ^= EFLG_CF;