From patchwork Wed Dec 15 16:43:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 413881 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBFGhbrx001119 for ; Wed, 15 Dec 2010 16:43:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751226Ab0LOQnd (ORCPT ); Wed, 15 Dec 2010 11:43:33 -0500 Received: from mail-fx0-f43.google.com ([209.85.161.43]:64469 "EHLO mail-fx0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751153Ab0LOQnc (ORCPT ); Wed, 15 Dec 2010 11:43:32 -0500 Received: by fxm18 with SMTP id 18so2250635fxm.2 for ; Wed, 15 Dec 2010 08:43:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type:content-transfer-encoding; bh=uUhN/M7P+1gAGHAJxqwfEcZC95S6LL53G5eOvia1yW8=; b=tyYClkhnwtJQVAYd/CuHQ3pJxczOh0t8PvTyLD7IfsGRLFpe9QfzYEKkdi3hlBdmWH AwrBFbFG0nsO7A1FFIqza2p8mV0OvJyTIxowBxAUdXPvwN9ud7yoSPcUwFm1fYhEh/QP eRHfpMTVsS60Gepu5c8c2dzlhF9z9FhbkSGLc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; b=oloFUxPNhKl1U0FqkUUyt5VC3tX3zIOEtFkEWoqgWw9lDWEEP3qajS9HedXCEbjkKN F0RTeawleqwYDk6mPyvNEiudHMXw6CZmbErzrmUq8N6/ml2zg/eAbKEnE3wmJWUhTI52 9cw7sBANi3kdHANrY5+EOjiqz0Tg6EX9tCzqI= Received: by 10.223.89.142 with SMTP id e14mr7436110fam.143.1292431411228; Wed, 15 Dec 2010 08:43:31 -0800 (PST) Received: from amd (x097031.dynamic.ppp.asahi-net.or.jp [122.249.97.31]) by mx.google.com with ESMTPS id n3sm522827fax.31.2010.12.15.08.43.28 (version=SSLv3 cipher=RC4-MD5); Wed, 15 Dec 2010 08:43:30 -0800 (PST) Date: Thu, 16 Dec 2010 01:43:26 +0900 From: Takuya Yoshikawa To: avi@redhat.com, mtosatti@redhat.com Cc: kvm@vger.kernel.org, yoshikawa.takuya@oss.ntt.co.jp, kvm-ia64@vger.kernel.org Subject: [PATCH 2/3] KVM: Centralize slots_lock aquisition during KVM_CREATE_IRQCHIP Message-Id: <20101216014326.9210211a.takuya.yoshikawa@gmail.com> In-Reply-To: <20101216013917.a8a8bab9.takuya.yoshikawa@gmail.com> References: <20101216013917.a8a8bab9.takuya.yoshikawa@gmail.com> X-Mailer: Sylpheed 3.1.0beta2 (GTK+ 2.22.0; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 15 Dec 2010 16:43:38 +0000 (UTC) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index 70d224d..060c594 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -946,7 +946,9 @@ long kvm_arch_vm_ioctl(struct file *filp, } case KVM_CREATE_IRQCHIP: r = -EFAULT; + mutex_lock(&kvm->slots_lock); r = kvm_ioapic_init(kvm); + mutex_unlock(&kvm->slots_lock); if (r) goto out; r = kvm_setup_default_irq_routing(kvm); diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c index f628234..37d24bc 100644 --- a/arch/x86/kvm/i8259.c +++ b/arch/x86/kvm/i8259.c @@ -580,9 +580,7 @@ struct kvm_pic *kvm_create_pic(struct kvm *kvm) * Initialize PIO device */ kvm_iodevice_init(&s->dev, &picdev_ops); - mutex_lock(&kvm->slots_lock); ret = kvm_io_bus_register_dev(kvm, KVM_PIO_BUS, &s->dev); - mutex_unlock(&kvm->slots_lock); if (ret < 0) { kfree(s); return NULL; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 3113aaf..736ab93 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3300,6 +3300,7 @@ long kvm_arch_vm_ioctl(struct file *filp, struct kvm_pic *vpic; mutex_lock(&kvm->lock); + mutex_lock(&kvm->slots_lock); r = -EEXIST; if (kvm->arch.vpic) goto create_irqchip_unlock; @@ -3308,10 +3309,8 @@ long kvm_arch_vm_ioctl(struct file *filp, if (vpic) { r = kvm_ioapic_init(kvm); if (r) { - mutex_lock(&kvm->slots_lock); kvm_io_bus_unregister_dev(kvm, KVM_PIO_BUS, &vpic->dev); - mutex_unlock(&kvm->slots_lock); kfree(vpic); goto create_irqchip_unlock; } @@ -3322,14 +3321,13 @@ long kvm_arch_vm_ioctl(struct file *filp, smp_wmb(); r = kvm_setup_default_irq_routing(kvm); if (r) { - mutex_lock(&kvm->slots_lock); mutex_lock(&kvm->irq_lock); kvm_ioapic_destroy(kvm); kvm_destroy_pic(kvm); mutex_unlock(&kvm->irq_lock); - mutex_unlock(&kvm->slots_lock); } create_irqchip_unlock: + mutex_unlock(&kvm->slots_lock); mutex_unlock(&kvm->lock); break; } diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c index 0b9df83..532bffc 100644 --- a/virt/kvm/ioapic.c +++ b/virt/kvm/ioapic.c @@ -393,9 +393,7 @@ int kvm_ioapic_init(struct kvm *kvm) kvm_ioapic_reset(ioapic); kvm_iodevice_init(&ioapic->dev, &ioapic_mmio_ops); ioapic->kvm = kvm; - mutex_lock(&kvm->slots_lock); ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, &ioapic->dev); - mutex_unlock(&kvm->slots_lock); if (ret < 0) { kvm->arch.vioapic = NULL; kfree(ioapic);