Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14364656 authored by Avi Kivity's avatar Avi Kivity Committed by Linus Torvalds
Browse files

[PATCH] KVM: MMU: Treat user-mode faults as a hint that a page is no longer a page table



Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
Acked-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 32b35627
Loading
Loading
Loading
Loading
+12 −1
Original line number Original line Diff line number Diff line
@@ -271,6 +271,7 @@ static int FNAME(fix_write_pf)(struct kvm_vcpu *vcpu,
	pt_element_t *guest_ent;
	pt_element_t *guest_ent;
	int writable_shadow;
	int writable_shadow;
	gfn_t gfn;
	gfn_t gfn;
	struct kvm_mmu_page *page;


	if (is_writeble_pte(*shadow_ent))
	if (is_writeble_pte(*shadow_ent))
		return 0;
		return 0;
@@ -303,7 +304,17 @@ static int FNAME(fix_write_pf)(struct kvm_vcpu *vcpu,
	}
	}


	gfn = walker->gfn;
	gfn = walker->gfn;
	if (kvm_mmu_lookup_page(vcpu, gfn)) {

	if (user) {
		/*
		 * Usermode page faults won't be for page table updates.
		 */
		while ((page = kvm_mmu_lookup_page(vcpu, gfn)) != NULL) {
			pgprintk("%s: zap %lx %x\n",
				 __FUNCTION__, gfn, page->role.word);
			kvm_mmu_zap_page(vcpu, page);
		}
	} else if (kvm_mmu_lookup_page(vcpu, gfn)) {
		pgprintk("%s: found shadow page for %lx, marking ro\n",
		pgprintk("%s: found shadow page for %lx, marking ro\n",
			 __FUNCTION__, gfn);
			 __FUNCTION__, gfn);
		*write_pt = 1;
		*write_pt = 1;