From: Wei Yongjun Date: Thu, 15 Jul 2010 00:51:58 +0000 (+0800) Subject: KVM: x86 emulator: fix xchg instruction emulation X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c19b8bd60e19308d5583ef200ddcc782d85d9543;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git KVM: x86 emulator: fix xchg instruction emulation If the destination is a memory operand and the memory cannot map to a valid page, the xchg instruction emulation and locked instruction will not work on io regions and stuck in endless loop. We should emulate exchange as write to fix it. Signed-off-by: Wei Yongjun Acked-by: Gleb Natapov Signed-off-by: Marcelo Tosatti --- diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 689c2c3182ab..97aab036dabf 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3562,6 +3562,10 @@ static int emulator_cmpxchg_emulated(unsigned long addr, goto emul_write; page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT); + if (is_error_page(page)) { + kvm_release_page_clean(page); + goto emul_write; + } kaddr = kmap_atomic(page, KM_USER0); kaddr += offset_in_page(gpa);