Skip to content

Commit

Permalink
KVM: MMU: only write protect mappings at pagetable level
Browse files Browse the repository at this point in the history
If a pagetable contains a writeable large spte, all of its sptes will be
write protected, including non-leaf ones, leading to endless pagefaults.

Do not write protect pages above PT_PAGE_TABLE_LEVEL, as the spte fault
paths assume non-leaf sptes are writable.

Tested-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
  • Loading branch information
Marcelo Tosatti authored and Avi Kivity committed Jan 12, 2011
1 parent 16d8f72 commit e49146d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arch/x86/kvm/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -3445,6 +3445,9 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot)
if (!test_bit(slot, sp->slot_bitmap))
continue;

if (sp->role.level != PT_PAGE_TABLE_LEVEL)
continue;

pt = sp->spt;
for (i = 0; i < PT64_ENT_PER_PAGE; ++i)
/* avoid RMW */
Expand Down

0 comments on commit e49146d

Please sign in to comment.