KVM: MMU: Fix incorrect direct page write protection due to ro host page
authorAvi Kivity <avi@redhat.com>
Sun, 12 Dec 2010 17:30:55 +0000 (19:30 +0200)
committerAvi Kivity <avi@redhat.com>
Wed, 12 Jan 2011 09:30:51 +0000 (11:30 +0200)
commitd3c422bd33388e6fe6777bde0e9bd20152133083
treea71812ddeb38943b7feb8a6f72c5540176d2c923
parent5c663a1534d27d817e17eed06a83d08f497f9f4f
KVM: MMU: Fix incorrect direct page write protection due to ro host page

If KVM sees a read-only host page, it will map it as read-only to prevent
breaking a COW.  However, if the page was part of a large guest page, KVM
incorrectly extends the write protection to the entire large page frame
instead of limiting it to the normal host page.

This results in the instantiation of a new shadow page with read-only access.

If this happens for a MOVS instruction that moves memory between two normal
pages, within a single large page frame, and mapped within the guest as a
large page, and if, in addition, the source operand is not writeable in the
host (perhaps due to KSM), then KVM will instantiate a read-only direct
shadow page, instantiate an spte for the source operand, then instantiate
a new read/write direct shadow page and instantiate an spte for the
destination operand.  Since these two sptes are in different shadow pages,
MOVS will never see them at the same time and the guest will not make
progress.

Fix by mapping the direct shadow page read/write, and only marking the
host page read-only.

Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/paging_tmpl.h