]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
KVM: Fix off-by-one when writing to a nonpae guest pde
authorAvi Kivity <avi@qumranet.com>
Wed, 18 Apr 2007 08:18:18 +0000 (11:18 +0300)
committerAvi Kivity <avi@qumranet.com>
Thu, 19 Apr 2007 15:39:26 +0000 (18:39 +0300)
Nonpae guest pdes are shadowed by two pae ptes, so we double the offset
twice: once to account for the pte size difference, and once because we
need to shadow pdes for a single guest pde.

But when writing to the upper guest pde we also need to truncate the
lower bits, otherwise the multiply shifts these bits into the pde index
and causes an access to the wrong shadow pde.  If we're at the end of the
page (accessing the very last guest pde) we can even overflow into the
next host page and oops.

Signed-off-by: Avi Kivity <avi@qumranet.com>
drivers/kvm/mmu.c

index e85b4c7c36f7139bc20a7bcb3138ac4edb654acd..cab26f301eab5caed62b1a3dcf8c4c7896b23d8b 100644 (file)
@@ -1171,6 +1171,7 @@ void kvm_mmu_pre_write(struct kvm_vcpu *vcpu, gpa_t gpa, int bytes)
                         * and zap two pdes instead of one.
                         */
                        if (level == PT32_ROOT_LEVEL) {
+                               page_offset &= ~7; /* kill rounding error */
                                page_offset <<= 1;
                                npte = 2;
                        }