From: Paolo Bonzini <pbonzini@redhat.com>
To: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: joro@8bytes.org, jon.grimm@amd.com, mlevitsk@redhat.com
Subject: Re: [PATCH v2] KVM: SVM: Disable AVIC before setting V_IRQ
Date: Thu, 7 May 2020 10:27:00 +0200 [thread overview]
Message-ID: <793e7151-e14c-f254-7911-a4371ad635aa@redhat.com> (raw)
In-Reply-To: <1588818939-54264-1-git-send-email-suravee.suthikulpanit@amd.com>
On 07/05/20 04:35, Suravee Suthikulpanit wrote:
> The commit 64b5bd270426 ("KVM: nSVM: ignore L1 interrupt window
> while running L2 with V_INTR_MASKING=1") introduced a WARN_ON,
> which checks if AVIC is enabled when trying to set V_IRQ
> in the VMCB for enabling irq window.
>
> The following warning is triggered because the requesting vcpu
> (to deactivate AVIC) does not get to process APICv update request
> for itself until the next #vmexit.
>
> WARNING: CPU: 0 PID: 118232 at arch/x86/kvm/svm/svm.c:1372 enable_irq_window+0x6a/0xa0 [kvm_amd]
> RIP: 0010:enable_irq_window+0x6a/0xa0 [kvm_amd]
> Call Trace:
> kvm_arch_vcpu_ioctl_run+0x6e3/0x1b50 [kvm]
> ? kvm_vm_ioctl_irq_line+0x27/0x40 [kvm]
> ? _copy_to_user+0x26/0x30
> ? kvm_vm_ioctl+0xb3e/0xd90 [kvm]
> ? set_next_entity+0x78/0xc0
> kvm_vcpu_ioctl+0x236/0x610 [kvm]
> ksys_ioctl+0x8a/0xc0
> __x64_sys_ioctl+0x1a/0x20
> do_syscall_64+0x58/0x210
> entry_SYSCALL_64_after_hwframe+0x44/0xa9
>
> Fixes by sending APICV update request to all other vcpus, and
> immediately update APIC for itself.
>
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> Link: https://lkml.org/lkml/2020/5/2/167
> Fixes: 64b5bd270426 ("KVM: nSVM: ignore L1 interrupt window while running L2 with V_INTR_MASKING=1")
> ---
> arch/x86/kvm/x86.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index df473f9..69a01ea 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -8085,6 +8085,7 @@ void kvm_vcpu_update_apicv(struct kvm_vcpu *vcpu)
> */
> void kvm_request_apicv_update(struct kvm *kvm, bool activate, ulong bit)
> {
> + struct kvm_vcpu *except;
> unsigned long old, new, expected;
>
> if (!kvm_x86_ops.check_apicv_inhibit_reasons ||
> @@ -8110,7 +8111,17 @@ void kvm_request_apicv_update(struct kvm *kvm, bool activate, ulong bit)
> trace_kvm_apicv_update_request(activate, bit);
> if (kvm_x86_ops.pre_update_apicv_exec_ctrl)
> kvm_x86_ops.pre_update_apicv_exec_ctrl(kvm, activate);
> - kvm_make_all_cpus_request(kvm, KVM_REQ_APICV_UPDATE);
> +
> + /*
> + * Sending request to update APICV for all other vcpus,
> + * while update the calling vcpu immediately instead of
> + * waiting for another #VMEXIT to handle the request.
> + */
> + except = kvm_get_running_vcpu();
> + kvm_make_all_cpus_request_except(kvm, KVM_REQ_APICV_UPDATE,
> + except);
> + if (except)
> + kvm_vcpu_update_apicv(except);
> }
> EXPORT_SYMBOL_GPL(kvm_request_apicv_update);
>
>
Queued, thanks.
Paolo
next prev parent reply other threads:[~2020-05-07 8:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-07 2:35 [PATCH v2] KVM: SVM: Disable AVIC before setting V_IRQ Suravee Suthikulpanit
2020-05-07 8:27 ` Paolo Bonzini [this message]
2020-05-10 12:13 ` Maxim Levitsky
2020-05-08 3:42 ` kbuild test robot
2020-05-08 15:32 ` kbuild test robot
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=793e7151-e14c-f254-7911-a4371ad635aa@redhat.com \
--to=pbonzini@redhat.com \
--cc=jon.grimm@amd.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mlevitsk@redhat.com \
--cc=suravee.suthikulpanit@amd.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;
as well as URLs for NNTP newsgroup(s).