Skip to content

Commit

Permalink
KVM: x86 emulator: fix xchg instruction emulation
Browse files Browse the repository at this point in the history
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 <yjwei@cn.fujitsu.com>
Acked-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
  • Loading branch information
Wei Yongjun authored and Avi Kivity committed Aug 2, 2010
1 parent 9195c4d commit c19b8bd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/x86/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c19b8bd

Please sign in to comment.