KVM: Reduce misfirings of the fork detector
The kvm mmu tries to detects forks by looking for repeated writes to a page table. If it sees a fork, it unshadows the page table so the page table copying can proceed at native speed instead of being emulated. However, the detector also triggered on simple demand paging access patterns: a linear walk of memory would of course cause repeated writes to the same pagetable page, causing it to unshadow prematurely. Fix by resetting the fork detector if we detect a demand fault. Signed-off-by: Avi Kivity <avi@qumranet.com>
This commit is contained in:
@@ -421,6 +421,7 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
|
|||||||
pgprintk("%s: guest page fault\n", __FUNCTION__);
|
pgprintk("%s: guest page fault\n", __FUNCTION__);
|
||||||
inject_page_fault(vcpu, addr, walker.error_code);
|
inject_page_fault(vcpu, addr, walker.error_code);
|
||||||
FNAME(release_walker)(&walker);
|
FNAME(release_walker)(&walker);
|
||||||
|
vcpu->last_pt_write_count = 0; /* reset fork detector */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,6 +443,9 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
|
|||||||
|
|
||||||
FNAME(release_walker)(&walker);
|
FNAME(release_walker)(&walker);
|
||||||
|
|
||||||
|
if (!write_pt)
|
||||||
|
vcpu->last_pt_write_count = 0; /* reset fork detector */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* mmio: emulate if accessible, otherwise its a guest fault.
|
* mmio: emulate if accessible, otherwise its a guest fault.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user