From: Paolo Bonzini <pbonzini@redhat.com>
To: Wanpeng Li <kernellwp@gmail.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
"Wanpeng Li" <wanpeng.li@hotmail.com>
Subject: Re: [PATCH v5 3/4] KVM: async_pf: Force a nested vmexit if the injected #PF is async_pf
Date: Tue, 27 Jun 2017 15:40:41 +0200 [thread overview]
Message-ID: <18eb67d5-d426-e69d-49d5-d8c434f40da7@redhat.com> (raw)
In-Reply-To: <1498528021-5115-4-git-send-email-wanpeng.li@hotmail.com>
On 27/06/2017 03:47, Wanpeng Li wrote:
> -static int nested_vmx_check_exception(struct kvm_vcpu *vcpu, unsigned nr)
> +static int nested_vmx_check_exception(struct kvm_vcpu *vcpu)
> {
> struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
> + unsigned int nr = vcpu->arch.exception.nr;
>
> - if (!(vmcs12->exception_bitmap & (1u << nr)))
> + if (!((vmcs12->exception_bitmap & (1u << nr)) ||
> + (nr == PF_VECTOR && vcpu->arch.exception.async_page_fault)))
> return 0;
>
> + if (vcpu->arch.exception.async_page_fault) {
> + vmcs_write32(VM_EXIT_INTR_ERROR_CODE, vcpu->arch.exception.error_code);
> + nested_vmx_vmexit(vcpu, EXIT_REASON_EXCEPTION_NMI,
> + PF_VECTOR | INTR_TYPE_HARD_EXCEPTION |
> + INTR_INFO_DELIVER_CODE_MASK | INTR_INFO_VALID_MASK,
> + vcpu->arch.apf.nested_apf_token);
> + return 1;
> + }
> +
> nested_vmx_vmexit(vcpu, EXIT_REASON_EXCEPTION_NMI,
> vmcs_read32(VM_EXIT_INTR_INFO),
> vmcs_readl(EXIT_QUALIFICATION));
> @@ -2442,7 +2453,7 @@ static void vmx_queue_exception(struct kvm_vcpu *vcpu)
> u32 intr_info = nr | INTR_INFO_VALID_MASK;
>
> if (!reinject && is_guest_mode(vcpu) &&
> - nested_vmx_check_exception(vcpu, nr))
> + nested_vmx_check_exception(vcpu))
> return;
>
> if (has_error_code) {
The corresponding change for svm.c should be:
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 6e3095d1bad4..b92f56b98844 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2391,15 +2391,19 @@ static int nested_svm_check_exception(struct vcpu_svm *svm, unsigned nr,
if (!is_guest_mode(&svm->vcpu))
return 0;
+ vmexit = nested_svm_intercept(svm);
+ if (vmexit != NESTED_EXIT_DONE)
+ return 0;
+
svm->vmcb->control.exit_code = SVM_EXIT_EXCP_BASE + nr;
svm->vmcb->control.exit_code_hi = 0;
svm->vmcb->control.exit_info_1 = error_code;
- svm->vmcb->control.exit_info_2 = svm->vcpu.arch.cr2;
-
- vmexit = nested_svm_intercept(svm);
- if (vmexit == NESTED_EXIT_DONE)
- svm->nested.exit_required = true;
+ if (svm->vcpu.arch.exception.nested_apf)
+ svm->vmcb->control.exit_info_2 = svm->vcpu.arch.apf.nested_apf_token;
+ else
+ svm->vmcb->control.exit_info_2 = svm->vcpu.arch.cr2;
+ svm->nested.exit_required = true;
return vmexit;
}
@@ -2592,7 +2596,7 @@ static int nested_svm_intercept(struct vcpu_svm *svm)
vmexit = NESTED_EXIT_DONE;
/* async page fault always cause vmexit */
else if ((exit_code == SVM_EXIT_EXCP_BASE + PF_VECTOR) &&
- svm->apf_reason != 0)
+ svm->vcpu.arch.exception.nested_apf)
vmexit = NESTED_EXIT_DONE;
break;
}
(where I'm already using the "nested_apf" name I proposed in the other email.
Paolo
next prev parent reply other threads:[~2017-06-27 13:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-27 1:46 [PATCH v5 0/4] KVM: async_pf: Fix async pf exception injection Wanpeng Li
2017-06-27 1:46 ` [PATCH v5 1/4] KVM: x86: Simple kvm_x86_ops->queue_exception parameter Wanpeng Li
2017-06-27 1:46 ` [PATCH v5 2/4] KVM: async_pf: Add L1 guest async_pf #PF vmexit handler Wanpeng Li
2017-06-27 13:30 ` Paolo Bonzini
2017-06-27 22:40 ` Wanpeng Li
2017-06-27 1:47 ` [PATCH v5 3/4] KVM: async_pf: Force a nested vmexit if the injected #PF is async_pf Wanpeng Li
2017-06-27 13:40 ` Paolo Bonzini [this message]
2017-06-27 1:47 ` [PATCH v5 4/4] KVM: async_pf: Let host know whether the guest support delivery async_pf as #PF vmexit Wanpeng Li
2017-06-27 13:19 ` Paolo Bonzini
2017-06-27 22:49 ` Wanpeng Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=18eb67d5-d426-e69d-49d5-d8c434f40da7@redhat.com \
--to=pbonzini@redhat.com \
--cc=kernellwp@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rkrcmar@redhat.com \
--cc=wanpeng.li@hotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®