Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752110AbdI2Oc7 (ORCPT ); Fri, 29 Sep 2017 10:32:59 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35368 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751224AbdI2Oc4 (ORCPT ); Fri, 29 Sep 2017 10:32:56 -0400 X-Google-Smtp-Source: AOwi7QB1Bmydg9OTFS7BKtbbUfmu3f+s5t9/IIoVEhRX4fNNlmA6U5YwMZS8xODefxa2ZVn0/H8Ckw== Subject: Re: [PATCH RESEND] KVM: nVMX: Fix nested #PF intends to break L1's vmlauch/vmresume To: Wanpeng Li , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Wanpeng Li References: <1506647804-3531-1-git-send-email-wanpeng.li@hotmail.com> From: Paolo Bonzini Message-ID: Date: Fri, 29 Sep 2017 16:32:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1506647804-3531-1-git-send-email-wanpeng.li@hotmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2269 Lines: 56 On 29/09/2017 03:16, Wanpeng Li wrote: > From: Wanpeng Li > > ------------[ cut here ]------------ > WARNING: CPU: 4 PID: 5280 at /home/kernel/linux/arch/x86/kvm//vmx.c:11394 nested_vmx_vmexit+0xc2b/0xd70 [kvm_intel] > CPU: 4 PID: 5280 Comm: qemu-system-x86 Tainted: G W OE 4.13.0+ #17 > RIP: 0010:nested_vmx_vmexit+0xc2b/0xd70 [kvm_intel] > Call Trace: > ? emulator_read_emulated+0x15/0x20 [kvm] > ? segmented_read+0xae/0xf0 [kvm] > vmx_inject_page_fault_nested+0x60/0x70 [kvm_intel] > ? vmx_inject_page_fault_nested+0x60/0x70 [kvm_intel] > x86_emulate_instruction+0x733/0x810 [kvm] > vmx_handle_exit+0x2f4/0xda0 [kvm_intel] > ? kvm_arch_vcpu_ioctl_run+0xd2f/0x1c60 [kvm] > kvm_arch_vcpu_ioctl_run+0xdab/0x1c60 [kvm] > ? kvm_arch_vcpu_load+0x62/0x230 [kvm] > kvm_vcpu_ioctl+0x340/0x700 [kvm] > ? kvm_vcpu_ioctl+0x340/0x700 [kvm] > ? __fget+0xfc/0x210 > do_vfs_ioctl+0xa4/0x6a0 > ? __fget+0x11d/0x210 > SyS_ioctl+0x79/0x90 > entry_SYSCALL_64_fastpath+0x23/0xc2 > > A nested #PF is triggered during L0 emulating instruction for L2. However, it > doesn't consider we should not break L1's vmlauch/vmresme. This patch fixes > it by queuing the #PF exception instead ,requesting an immediate VM exit from > L2 and keeping the exception for L1 pending for a subsequent nested VM exit. > > Cc: Paolo Bonzini > Cc: Radim Krčmář > Signed-off-by: Wanpeng Li > --- > arch/x86/kvm/vmx.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index c83d28b..1ca91c8 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -9840,7 +9840,8 @@ static void vmx_inject_page_fault_nested(struct kvm_vcpu *vcpu, > > WARN_ON(!is_guest_mode(vcpu)); > > - if (nested_vmx_is_page_fault_vmexit(vmcs12, fault->error_code)) { > + if (nested_vmx_is_page_fault_vmexit(vmcs12, fault->error_code) && > + !to_vmx(vcpu)->nested.nested_run_pending) { > vmcs12->vm_exit_intr_error_code = fault->error_code; > nested_vmx_vmexit(vcpu, EXIT_REASON_EXCEPTION_NMI, > PF_VECTOR | INTR_TYPE_HARD_EXCEPTION | > Thanks, I guess that's better than nothing for now! Paolo