aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/mmu.c
diff options
context:
space:
mode:
authorXiao Guangrong <xiaoguangrong@cn.fujitsu.com>2011-03-04 05:56:41 -0500
committerMarcelo Tosatti <mtosatti@redhat.com>2011-03-17 12:08:32 -0400
commitda8dc75f0c4663a568a0ed4e744c6d55d428d8b6 (patch)
treeec0caa9ac963af4d8c1a58d3f7e6933a80699e11 /arch/x86/kvm/mmu.c
parent38a778aa1899b9c6cf3e300a02782c9b78c547ab (diff)
KVM: MMU: fix kvm_mmu_slot_remove_write_access dropping intermediate W bits
Only remove write access in the last sptes. Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/mmu.c')
-rw-r--r--arch/x86/kvm/mmu.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index b6a9963400a7..b9bf016d7f0f 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -3540,12 +3540,17 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot)
3540 3540
3541 pt = sp->spt; 3541 pt = sp->spt;
3542 for (i = 0; i < PT64_ENT_PER_PAGE; ++i) { 3542 for (i = 0; i < PT64_ENT_PER_PAGE; ++i) {
3543 if (sp->role.level != PT_PAGE_TABLE_LEVEL 3543 if (!is_shadow_present_pte(pt[i]) ||
3544 && is_large_pte(pt[i])) { 3544 !is_last_spte(pt[i], sp->role.level))
3545 continue;
3546
3547 if (is_large_pte(pt[i])) {
3545 drop_spte(kvm, &pt[i], 3548 drop_spte(kvm, &pt[i],
3546 shadow_trap_nonpresent_pte); 3549 shadow_trap_nonpresent_pte);
3547 --kvm->stat.lpages; 3550 --kvm->stat.lpages;
3551 continue;
3548 } 3552 }
3553
3549 /* avoid RMW */ 3554 /* avoid RMW */
3550 if (is_writable_pte(pt[i])) 3555 if (is_writable_pte(pt[i]))
3551 update_spte(&pt[i], pt[i] & ~PT_WRITABLE_MASK); 3556 update_spte(&pt[i], pt[i] & ~PT_WRITABLE_MASK);