From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH v3 03/24] KVM: x86: check against irqchip_mode in kvm_set_routing_entry() Date: Wed, 12 Apr 2017 20:36:55 +0200 Message-ID: <20170412183655.GB20145@potion> References: <20170407085041.5257-1-david@redhat.com> <20170407085041.5257-4-david@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, Paolo Bonzini , Peter Xu To: David Hildenbrand Return-path: Received: from mx1.redhat.com ([209.132.183.28]:45640 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753882AbdDLShE (ORCPT ); Wed, 12 Apr 2017 14:37:04 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F395A64DAA for ; Wed, 12 Apr 2017 18:37:03 +0000 (UTC) Content-Disposition: inline In-Reply-To: <20170407085041.5257-4-david@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 2017-04-07 10:50+0200, David Hildenbrand: > Let's replace the checks for pic_in_kernel() and ioapic_in_kernel() by > checks against irqchip_mode. > > Also make sure that creation of any route is only possible if we have > an lapic in kernel (irqchip_in_kernel()) or if we are currently > inititalizing the irqchip. > > This is necessary to switch pic_in_kernel() and ioapic_in_kernel() to > irqchip_mode, too. > > Signed-off-by: David Hildenbrand > --- > arch/x86/kvm/irq_comm.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c > index 6825cd3..2e5eec8 100644 > --- a/arch/x86/kvm/irq_comm.c > +++ b/arch/x86/kvm/irq_comm.c > @@ -282,24 +282,26 @@ int kvm_set_routing_entry(struct kvm *kvm, > int delta; > unsigned max_pin; > > + /* also allow creation of routes during KVM_IRQCHIP_INIT_IN_PROGRESS */ > + if (kvm->arch.irqchip_mode == KVM_IRQCHIP_NONE) > + goto out; > + > + /* Matches smp_wmb() when setting irqchip_mode */ > + smp_rmb(); This barrier is superfluous as well ... aren't all callers using kvm->lock to provide ordering? The check for KVM_IRQCHIP_NONE would prevent nothing if we could catch the initialization from the outside and hence need a barrier. Thanks.