Message ID | 20200511164752.2158645-1-vkuznets@redhat.com (mailing list archive) |
---|---|
Headers | show |
Series | KVM: x86: Interrupt-based mechanism for async_pf 'page present' notifications | expand |
Hi Vitaly, Are there any corresponding qemu patches as well to enable new functionality. Wanted to test it. Thanks Vivek On Mon, May 11, 2020 at 06:47:44PM +0200, Vitaly Kuznetsov wrote: > Concerns were expressed around (ab)using #PF for KVM's async_pf mechanism, > it seems that re-using #PF exception for a PV mechanism wasn't a great > idea after all. The Grand Plan is to switch to using e.g. #VE for 'page > not present' events and normal APIC interrupts for 'page ready' events. > This series does the later. > > Changes since RFC: > - Using #PF for 'page ready' is deprecated and removed [Paolo Bonzini] > - 'reason' field in 'struct kvm_vcpu_pv_apf_data' is not used for 'page ready' > notifications and 'pageready_token' is not used for 'page not present' events > [Paolo Bonzini] > - Renamed MSR_KVM_ASYNC_PF2 -> MSR_KVM_ASYNC_PF_INT [Peter Xu] > - Drop 'enabled' field from MSR_KVM_ASYNC_PF_INT [Peter Xu] > - Other minor changes supporting the above. > > Vitaly Kuznetsov (8): > Revert "KVM: async_pf: Fix #DF due to inject "Page not Present" and > "Page Ready" exceptions simultaneously" > KVM: x86: extend struct kvm_vcpu_pv_apf_data with token info > KVM: introduce kvm_read_guest_offset_cached() > KVM: x86: interrupt based APF page-ready event delivery > KVM: x86: acknowledgment mechanism for async pf page ready > notifications > KVM: x86: announce KVM_FEATURE_ASYNC_PF_INT > KVM: x86: Switch KVM guest to using interrupts for page ready APF > delivery > KVM: x86: drop KVM_PV_REASON_PAGE_READY case from > kvm_handle_page_fault() > > Documentation/virt/kvm/cpuid.rst | 6 ++ > Documentation/virt/kvm/msr.rst | 106 ++++++++++++++------ > arch/s390/include/asm/kvm_host.h | 2 + > arch/x86/entry/entry_32.S | 5 + > arch/x86/entry/entry_64.S | 5 + > arch/x86/include/asm/hardirq.h | 3 + > arch/x86/include/asm/irq_vectors.h | 6 +- > arch/x86/include/asm/kvm_host.h | 7 +- > arch/x86/include/asm/kvm_para.h | 6 ++ > arch/x86/include/uapi/asm/kvm_para.h | 11 ++- > arch/x86/kernel/irq.c | 9 ++ > arch/x86/kernel/kvm.c | 42 ++++++-- > arch/x86/kvm/cpuid.c | 3 +- > arch/x86/kvm/mmu/mmu.c | 10 +- > arch/x86/kvm/x86.c | 142 ++++++++++++++++++--------- > include/linux/kvm_host.h | 3 + > include/uapi/linux/kvm.h | 1 + > virt/kvm/async_pf.c | 10 ++ > virt/kvm/kvm_main.c | 19 +++- > 19 files changed, 295 insertions(+), 101 deletions(-) > > -- > 2.25.4 >
Vivek Goyal <vgoyal@redhat.com> writes: > Hi Vitaly, > > Are there any corresponding qemu patches as well to enable new > functionality. Wanted to test it. > Yes, right you are, I forgot to even mention this in the blurb. Please find patches against current 'master' attached. With '-cpu host' the feature gets enabled automatically. Note, guest kernel needs to be updated too.
On Mon, May 11, 2020 at 06:47:44PM +0200, Vitaly Kuznetsov wrote: > Concerns were expressed around (ab)using #PF for KVM's async_pf mechanism, > it seems that re-using #PF exception for a PV mechanism wasn't a great > idea after all. The Grand Plan is to switch to using e.g. #VE for 'page > not present' events and normal APIC interrupts for 'page ready' events. > This series does the later. Hi Vitaly, How does any of this impact nested virtualization code (if any). I have tried understanding that logic, but I have to admit, I could never get it. arch/x86/kvm/mmu/mmu.c int kvm_handle_page_fault(struct kvm_vcpu *vcpu, u64 error_code, u64 fault_address, char *insn, int insn_len) { switch (vcpu->arch.apf.host_apf_reason) { case KVM_PV_REASON_PAGE_NOT_PRESENT: kvm_async_pf_task_wait(fault_address, 0); case KVM_PV_REASON_PAGE_READY: kvm_async_pf_task_wake(fault_address); } } Vivek > > Changes since RFC: > - Using #PF for 'page ready' is deprecated and removed [Paolo Bonzini] > - 'reason' field in 'struct kvm_vcpu_pv_apf_data' is not used for 'page ready' > notifications and 'pageready_token' is not used for 'page not present' events > [Paolo Bonzini] > - Renamed MSR_KVM_ASYNC_PF2 -> MSR_KVM_ASYNC_PF_INT [Peter Xu] > - Drop 'enabled' field from MSR_KVM_ASYNC_PF_INT [Peter Xu] > - Other minor changes supporting the above. > > Vitaly Kuznetsov (8): > Revert "KVM: async_pf: Fix #DF due to inject "Page not Present" and > "Page Ready" exceptions simultaneously" > KVM: x86: extend struct kvm_vcpu_pv_apf_data with token info > KVM: introduce kvm_read_guest_offset_cached() > KVM: x86: interrupt based APF page-ready event delivery > KVM: x86: acknowledgment mechanism for async pf page ready > notifications > KVM: x86: announce KVM_FEATURE_ASYNC_PF_INT > KVM: x86: Switch KVM guest to using interrupts for page ready APF > delivery > KVM: x86: drop KVM_PV_REASON_PAGE_READY case from > kvm_handle_page_fault() > > Documentation/virt/kvm/cpuid.rst | 6 ++ > Documentation/virt/kvm/msr.rst | 106 ++++++++++++++------ > arch/s390/include/asm/kvm_host.h | 2 + > arch/x86/entry/entry_32.S | 5 + > arch/x86/entry/entry_64.S | 5 + > arch/x86/include/asm/hardirq.h | 3 + > arch/x86/include/asm/irq_vectors.h | 6 +- > arch/x86/include/asm/kvm_host.h | 7 +- > arch/x86/include/asm/kvm_para.h | 6 ++ > arch/x86/include/uapi/asm/kvm_para.h | 11 ++- > arch/x86/kernel/irq.c | 9 ++ > arch/x86/kernel/kvm.c | 42 ++++++-- > arch/x86/kvm/cpuid.c | 3 +- > arch/x86/kvm/mmu/mmu.c | 10 +- > arch/x86/kvm/x86.c | 142 ++++++++++++++++++--------- > include/linux/kvm_host.h | 3 + > include/uapi/linux/kvm.h | 1 + > virt/kvm/async_pf.c | 10 ++ > virt/kvm/kvm_main.c | 19 +++- > 19 files changed, 295 insertions(+), 101 deletions(-) > > -- > 2.25.4 >
Vivek Goyal <vgoyal@redhat.com> writes: > On Mon, May 11, 2020 at 06:47:44PM +0200, Vitaly Kuznetsov wrote: >> Concerns were expressed around (ab)using #PF for KVM's async_pf mechanism, >> it seems that re-using #PF exception for a PV mechanism wasn't a great >> idea after all. The Grand Plan is to switch to using e.g. #VE for 'page >> not present' events and normal APIC interrupts for 'page ready' events. >> This series does the later. > > Hi Vitaly, > > How does any of this impact nested virtualization code (if any). > > I have tried understanding that logic, but I have to admit, I could > never get it. > > arch/x86/kvm/mmu/mmu.c > > int kvm_handle_page_fault(struct kvm_vcpu *vcpu, u64 error_code, > u64 fault_address, char *insn, int insn_len) > { > switch (vcpu->arch.apf.host_apf_reason) { > case KVM_PV_REASON_PAGE_NOT_PRESENT: > kvm_async_pf_task_wait(fault_address, 0); > case KVM_PV_REASON_PAGE_READY: > kvm_async_pf_task_wake(fault_address); > } > } > "[PATCH 8/8] KVM: x86: drop KVM_PV_REASON_PAGE_READY case from kvm_handle_page_fault()" modifies this a little bit. Basically (and if I understand this correctly) we have the following APF related feature (bit 2 in MSR_KVM_ASYNC_PF_EN): "asynchronous page faults are delivered to L1 as #PF vmexits.". When enabled, it allows L0 to inject #PF when L2 guest is running. L1 will see this as '#PF vmexit' and the code you cite will do exactly what do_async_page_fault() is doing. When we switch to interrupt based delivery for 'page ready' events we don't need a special handling for them in L1 (as we don't need any special handling for all interrupts from devices in kernel when KVM guest is running). I have to admit I haven't tested nested scenario yet, "what could go wrong?" :-)