From: Paolo Bonzini <pbonzini@redhat.com>
To: Nicholas Krause <xerofoify@gmail.com>, gleb@kernel.org
Cc: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kvm:x86:Fix error handling in the function kvm_lapic_sync_to_vapic
Date: Tue, 11 Aug 2015 15:13:35 +0200 [thread overview]
Message-ID: <55C9F4FF.9090906@redhat.com> (raw)
In-Reply-To: <1439234760-26445-1-git-send-email-xerofoify@gmail.com>
On 10/08/2015 21:26, Nicholas Krause wrote:
> This fixes error handling in the function kvm_lapic_sync_to_vapic
> to check the value of the call to kvm_write_guest_cached to see if
> it failed by returning a error code and if so execute WARN_ON to
> allow the user to see in their logs the failure when executing the
> function kvm_lapic_sync_to_vapic.
>
> Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
> ---
> arch/x86/kvm/lapic.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 2a5ca97..f3946c0 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -1935,7 +1935,7 @@ static void apic_sync_pv_eoi_to_guest(struct kvm_vcpu *vcpu,
> void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu)
> {
> u32 data, tpr;
> - int max_irr, max_isr;
> + int max_irr, max_isr, ret;
> struct kvm_lapic *apic = vcpu->arch.apic;
>
> apic_sync_pv_eoi_to_guest(vcpu, apic);
> @@ -1952,8 +1952,9 @@ void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu)
> max_isr = 0;
> data = (tpr & 0xff) | ((max_isr & 0xf0) << 8) | (max_irr << 24);
>
> - kvm_write_guest_cached(vcpu->kvm, &vcpu->arch.apic->vapic_cache, &data,
> - sizeof(u32));
> + ret = kvm_write_guest_cached(vcpu->kvm, &vcpu->arch.apic->vapic_cache, &data,
> + sizeof(u32));
> + WARN_ON(ret);
> }
>
> int kvm_lapic_set_vapic_addr(struct kvm_vcpu *vcpu, gpa_t vapic_addr)
>
It shouldn't happen, but I cannot rule out that a guest cannot trigger
it. It would be a bug or bad behavior in the guest but, if it can, a
WARN message in the host dmesg would not be the right thing to do.
So I prefer to leave the return value unchecked.
Paolo
parent reply other threads:[~2015-08-11 13:13 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <1439234760-26445-1-git-send-email-xerofoify@gmail.com>]
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=55C9F4FF.9090906@redhat.com \
--to=pbonzini@redhat.com \
--cc=gleb@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=x86@kernel.org \
--cc=xerofoify@gmail.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