aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-04-18 04:18:18 -0400
committerAvi Kivity <avi@qumranet.com>2007-04-19 11:39:26 -0400
commit6b8d0f9b180cb93513bb65f705b299370f0357a1 (patch)
treef62483014f65a5f13f3ce0bf08c43394208ca7f6 /drivers/kvm
parent80d74d5123bf3aecd32302809c4e61bb8a16786b (diff)
KVM: Fix off-by-one when writing to a nonpae guest pde
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>
Diffstat (limited to 'drivers/kvm')
-rw-r--r--drivers/kvm/mmu.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c
index e85b4c7c36f7..cab26f301eab 100644
--- a/drivers/kvm/mmu.c
+++ b/drivers/kvm/mmu.c
@@ -1171,6 +1171,7 @@ void kvm_mmu_pre_write(struct kvm_vcpu *vcpu, gpa_t gpa, int bytes)
1171 * and zap two pdes instead of one. 1171 * and zap two pdes instead of one.
1172 */ 1172 */
1173 if (level == PT32_ROOT_LEVEL) { 1173 if (level == PT32_ROOT_LEVEL) {
1174 page_offset &= ~7; /* kill rounding error */
1174 page_offset <<= 1; 1175 page_offset <<= 1;
1175 npte = 2; 1176 npte = 2;
1176 } 1177 }