kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steve Rutherford <srutherford@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	mtosatti@redhat.com, rkrcmar@redhat.com
Subject: Re: [PATCH 4/4] KVM: x86: clean/fix memory barriers in irqchip_in_kernel
Date: Wed, 29 Jul 2015 20:32:08 -0700	[thread overview]
Message-ID: <20150730033208.GC15229@google.com> (raw)
In-Reply-To: <1438176538-26191-5-git-send-email-pbonzini@redhat.com>

On Wed, Jul 29, 2015 at 03:28:58PM +0200, Paolo Bonzini wrote:
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 2d62229aac26..23e47a0b054b 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3626,30 +3626,25 @@ long kvm_arch_vm_ioctl(struct file *filp,
>  			r = kvm_ioapic_init(kvm);
>  			if (r) {
>  				mutex_lock(&kvm->slots_lock);
> -				kvm_io_bus_unregister_dev(kvm, KVM_PIO_BUS,
> -							  &vpic->dev_master);
> -				kvm_io_bus_unregister_dev(kvm, KVM_PIO_BUS,
> -							  &vpic->dev_slave);
> -				kvm_io_bus_unregister_dev(kvm, KVM_PIO_BUS,
> -							  &vpic->dev_eclr);
> +				kvm_destroy_pic(vpic);
>  				mutex_unlock(&kvm->slots_lock);
> -				kfree(vpic);
>  				goto create_irqchip_unlock;
>  			}
>  		} else
>  			goto create_irqchip_unlock;
> -		smp_wmb();
> -		kvm->arch.vpic = vpic;
> -		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);
> +			kvm_destroy_pic(vpic);
>  			mutex_unlock(&kvm->irq_lock);
>  			mutex_unlock(&kvm->slots_lock);
> +			goto create_irqchip_unlock;
>  		}
> +		/* Write kvm->irq_routing before kvm->arch.vpic.  */
> +		smp_wmb();
I assume this pairs with irqchip_in_kernel? 
> +		kvm->arch.vpic = vpic;
>  	create_irqchip_unlock:
>  		mutex_unlock(&kvm->lock);
>  		break;
> -- 
> 1.8.3.1
> 

  reply	other threads:[~2015-07-30  3:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-29 13:28 [PATCH 0/4] KVM: cleanups around memory barriers and irqchip_in_kernel Paolo Bonzini
2015-07-29 13:28 ` [PATCH 1/4] KVM: x86: remove unnecessary memory barriers for shared MSRs Paolo Bonzini
2015-07-29 13:28 ` [PATCH 2/4] KVM: document memory barriers for kvm->vcpus/kvm->online_vcpus Paolo Bonzini
2015-07-30 11:40   ` Christian Borntraeger
2015-07-30 12:46     ` Paolo Bonzini
2015-07-30 13:57       ` Christian Borntraeger
2015-07-30 14:02         ` Paolo Bonzini
2015-07-30 14:05           ` Christian Borntraeger
2015-07-29 13:28 ` [PATCH 3/4] KVM: i8254: remove unnecessary irqchip_in_kernel check Paolo Bonzini
2015-07-30  4:36   ` Steve Rutherford
2015-07-30  7:25     ` Paolo Bonzini
2015-07-29 13:28 ` [PATCH 4/4] KVM: x86: clean/fix memory barriers in irqchip_in_kernel Paolo Bonzini
2015-07-30  3:32   ` Steve Rutherford [this message]
2015-07-30  7:26     ` Paolo Bonzini

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=20150730033208.GC15229@google.com \
    --to=srutherford@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.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;
as well as URLs for NNTP newsgroup(s).