On Fri, Feb 21, 2020 at 06:14:03PM +0100, Paolo Bonzini wrote: > On 19/02/20 16:16, Sean Christopherson wrote: > > The easy solution to that is to move retry_instruction() into emulate.c. > > That would also allow making x86_page_table_writing_insn() static. All > > other functions invoked from retry_instruction() are exposed via kvm_host.h. > > emulate.c is supposed to invoke no (or almost no) function outside the > ctxt->ops struct. In particular, retry_instruction() invokes > kvm_mmu_gva_to_gpa_write and kvm_mmu_unprotect_page. Ah, right. We could split the logic, e.g. if (x86_retry_pf_instruction(ctxt, cr2_or_gpa, emulation_type)) { gpa_t = gpa = cr2_or_gpa; if (!vcpu->arch.mmu->direct_map) gpa = kvm_mmu_gva_to_gpa_write(vcpu, cr2_or_gpa, NULL); kvm_mmu_unprotect_page(vcpu->kvm, gpa_to_gfn(gpa)); return 1; } but that's probably a net negative in terms of clarity. And there's also vcpu->arch.write_fault_to_shadow_pgtable, which is consumed only by reexecute_instruction(), and I 100% agree that that variable should stay in vcpu->arch. Moving one flag used to retry #PF instructions and not the other would be weird. That was a long winded way of saying I agree we should drop this patch :-)