From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758921AbcAKKAx (ORCPT ); Mon, 11 Jan 2016 05:00:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50349 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757463AbcAKKAw (ORCPT ); Mon, 11 Jan 2016 05:00:52 -0500 Subject: Re: [PATCH RESEND] kvm:x86:Fix error handling in the function kvm_lapic_sync_to_vapic To: Nicholas Krause , gleb@kernel.org References: <1452403705-17168-1-git-send-email-xerofoify@gmail.com> Cc: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org From: Paolo Bonzini Message-ID: <56937D4A.2010107@redhat.com> Date: Mon, 11 Jan 2016 11:00:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <1452403705-17168-1-git-send-email-xerofoify@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/01/2016 06:28, 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 > --- > 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) > Again... no. The error can be triggered by the guest. Incorrect behavior of the guest should *never* result in a WARN in the host. Paolo