KVM: X86: clear page flags when freeing kvm mmapping page
A message that is not in the archive (sent off-list or not yet received): [email protected]
Paolo Bonzini
maintainerQuoted 7 lines · On 10/10/2017 17:39, [email protected] wrote:
Quoted 2 lines
How did you know that this was a kvm_run page, and why is it the right thing to clear the flags?
first I can't repeat this "bad page report". But I add print message to trace. I found that kvm_run page is freed with page flags
PG_dirtyandPG_referenced. I don't think it is right status for freed page.
That would be the symptom, not the cause. So it would not be the right thing to clear the flags.
Quoted 4 lines
second,
kvm_runpage is mmaped in qemu with fd of "kvm-vcpu". It has special mmap function(kvm_vcpu_mmap),but when munmap is called thekvm_runpage goes into general munmap route.it is not suitable forkvm_runpage that is set dirty in munmap route.
There are many many cases where .mmap and .fault are defined but .munmap isn't, and none of them calls ClearPageDirty or ClearPageReferenced; see for example kernel/relay.c (whose only user is blktrace).
Can the page be dirty in those cases? If not, what makes KVM different?
Since you cannot reproduce the failure, this patch is basically untested. You need to dig deeper into what's happening, and provide a better justification for what you are doing. But generally, it's a bad sign if you're doing something special that no other device in the kernel is doing.
Paolo