From: Paolo Bonzini <pbonzini@redhat.com>
To: Peng Hao <penghao122@sina.com.cn>,
rkrcmar@redhat.com, tglx@linutronix.de, mingo@redhat.com,
hpa@zytor.com
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
x86@kernel.org, Peng Hao <peng.hao2@zte.com.cn>
Subject: Re: [PATCH] kvm/x86 : set meaningful return value
Date: Mon, 1 Oct 2018 16:06:29 +0200 [thread overview]
Message-ID: <078bbf7f-e494-4009-09e0-85c7f1edb73b@redhat.com> (raw)
In-Reply-To: <1538152913-3036-1-git-send-email-penghao122@sina.com.cn>
On 28/09/2018 18:41, Peng Hao wrote:
> From: Peng Hao <peng.hao2@zte.com.cn>
>
> kvm_irq_delivery_to_apic_fast()-->
> kvm_apic_map_get_dest_lapic()-->
> kvm_apic_disabled_lapic_found()
> kvm_apic_map_get_dest_lapic return with bitmap==0 and dst[i]==NULL,
> then (*r == -1) will be returned to qemu and "KVM: injection failed,
> MSI lost(Operation not permitted)" will be recorded in qemu log. The
> output is puzzling.
This makes sense, but I am not sure that ENXIO is any better...
In fact, in this case I think it's okay to just return zero. What about
this fix:
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index b756f1237ce3..d02515b8018f 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -957,14 +957,14 @@ bool kvm_irq_delivery_to_apic_fast(struct kvm
*kvm, struct kvm_lapic *src,
map = rcu_dereference(kvm->arch.apic_map);
ret = kvm_apic_map_get_dest_lapic(kvm, &src, irq, map, &dst, &bitmap);
- if (ret)
+ if (ret) {
+ *r = 0;
for_each_set_bit(i, &bitmap, 16) {
if (!dst[i])
continue;
- if (*r < 0)
- *r = 0;
*r += kvm_apic_set_irq(dst[i]->vcpu, irq, dest_map);
}
+ }
rcu_read_unlock();
return ret;
Paolo
> Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
> ---
> arch/x86/kvm/lapic.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index fbb0e6d..a8896b3 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -944,7 +944,7 @@ bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src,
> int i;
> bool ret;
>
> - *r = -1;
> + *r = -ENXIO;
>
> if (irq->shorthand == APIC_DEST_SELF) {
> *r = kvm_apic_set_irq(src->vcpu, irq, dest_map);
>
prev parent reply other threads:[~2018-10-01 14:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-28 16:41 Peng Hao
2018-10-01 14:06 ` Paolo Bonzini [this message]
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=078bbf7f-e494-4009-09e0-85c7f1edb73b@redhat.com \
--to=pbonzini@redhat.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peng.hao2@zte.com.cn \
--cc=penghao122@sina.com.cn \
--cc=rkrcmar@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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®