Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756407AbcKWV6W (ORCPT ); Wed, 23 Nov 2016 16:58:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53334 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753522AbcKWV6V (ORCPT ); Wed, 23 Nov 2016 16:58:21 -0500 Subject: Re: [PATCH] KVM: x86: check for pic and ioapic presence before use To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , linux-kernel@vger.kernel.org, kvm@vger.kernel.org References: <20161123202548.29324-1-rkrcmar@redhat.com> Cc: stable@vger.kernel.org, Dmitry Vyukov , Steve Rutherford From: Paolo Bonzini Message-ID: <06c15e9d-43fc-0d08-57e4-26440c441eb0@redhat.com> Date: Wed, 23 Nov 2016 22:58:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161123202548.29324-1-rkrcmar@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 23 Nov 2016 21:58:20 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 933 Lines: 29 On 23/11/2016 21:25, Radim Krčmář wrote: > diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c > index 25810b144b58..ddd63b8b176e 100644 > --- a/arch/x86/kvm/irq_comm.c > +++ b/arch/x86/kvm/irq_comm.c > @@ -41,6 +41,15 @@ static int kvm_set_pic_irq(struct kvm_kernel_irq_routing_entry *e, > bool line_status) > { > struct kvm_pic *pic = pic_irqchip(kvm); > + > + /* > + * XXX: rejecting pic routes when pic isn't in use would be better, > + * but the default routing table is installed while kvm->arch.vpic is > + * NULL and KVM_CREATE_IRQCHIP can race with KVM_SET_GSI_ROUTING. > + */ > + if (!pic) > + return -1; > + > return kvm_pic_set_irq(pic, e->irqchip.pin, irq_source_id, level); > } > Can you explain the race with the default routing table better? It seems to me that it can only make the routing table go from invalid to valid (there is no KVM_DESTROY_IRQCHIP) so it's benign. Paolo