All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoffer Dall <cdall@linaro.org>
To: Marc Zyngier <marc.zyngier@arm.com>
Cc: kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org,
	Eric Auger <eric.auger@redhat.com>
Subject: Re: [PATCH 7/8] KVM: arm/arm64: Register ITS iodev when setting base address
Date: Mon, 8 May 2017 21:21:53 +0200	[thread overview]
Message-ID: <20170508192153.GM28342@cbox> (raw)
In-Reply-To: <a33cabd3-cf92-1a49-7b47-8d35d3daab4d@arm.com>

On Mon, May 08, 2017 at 06:41:36PM +0100, Marc Zyngier wrote:
> Hi Christoffer,
> 
> On 08/05/17 12:54, Christoffer Dall wrote:
> > We have to register the ITS iodevice before running the VM, because in
> > migration scenarios, we may be restoring a live device that wishes to
> > inject MSIs before we get a chance to run the VM.
> > 
> > All we need to register the ITS io device is the base address of the
> > ITS, so we can simply register that when the base address of the ITS is
> > set.
> > 
> > Signed-off-by: Christoffer Dall <cdall@linaro.org>
> > ---
> >  virt/kvm/arm/vgic/vgic-its.c | 29 +----------------------------
> >  virt/kvm/arm/vgic/vgic-v3.c  |  8 --------
> >  virt/kvm/arm/vgic/vgic.h     |  1 -
> >  3 files changed, 1 insertion(+), 37 deletions(-)
> > 
> > diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
> > index 9f7105c..375c503 100644
> > --- a/virt/kvm/arm/vgic/vgic-its.c
> > +++ b/virt/kvm/arm/vgic/vgic-its.c
> > @@ -2390,7 +2390,7 @@ static int vgic_its_set_attr(struct kvm_device *dev,
> >  
> >  		its->vgic_its_base = addr;
> >  
> > -		return 0;
> > +		return vgic_register_its_iodev(dev->kvm, its);
> >  	}
> >  	case KVM_DEV_ARM_VGIC_GRP_CTRL: {
> >  		const struct vgic_its_abi *abi = vgic_its_get_abi(its);
> > @@ -2467,30 +2467,3 @@ int kvm_vgic_register_its_device(void)
> >  	return kvm_register_device_ops(&kvm_arm_vgic_its_ops,
> >  				       KVM_DEV_TYPE_ARM_VGIC_ITS);
> >  }
> 
> This patch has the unfortunate side effect of breaking kvmtool 
> (although the ITS support patches are not merged yet). The code 
> sequence now requires that KVM_DEV_ARM_VGIC_CTRL_INIT has been issued 
> on the ITS *before* we can set the ITS base address.
> 
> I find it a bit odd (I see KVM_DEV_ARM_VGIC_CTRL_INIT as a way to say 
> "I'm done, do what you must and make it work"), but that's obviously 
> what QEMU must be doing (the save/restore sequence hints at that, but I 
> only just realized the issue). Of course, kvmtool does the opposite.
> 
> But now that we've coupled setting the address and mapping the iodev, 
> there is not much that's left for KVM_DEV_ARM_VGIC_CTRL_INIT, and I 
> wonder why we're keeping it (other than for backward compatibility)?
> 
> We're now unable to set the address more than once (fair enough). What 
> is also interesting is that this makes it plain obvious that we have a 
> race between setting the address and registering the device (no lock is 
> taken here, and two threads could try and play a dirty game on us).
> 
> I've come up with the two following patches, that seem to make it work.

Both patches look good, thanks.

-Christoffer

WARNING: multiple messages have this Message-ID (diff)
From: cdall@linaro.org (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 7/8] KVM: arm/arm64: Register ITS iodev when setting base address
Date: Mon, 8 May 2017 21:21:53 +0200	[thread overview]
Message-ID: <20170508192153.GM28342@cbox> (raw)
In-Reply-To: <a33cabd3-cf92-1a49-7b47-8d35d3daab4d@arm.com>

On Mon, May 08, 2017 at 06:41:36PM +0100, Marc Zyngier wrote:
> Hi Christoffer,
> 
> On 08/05/17 12:54, Christoffer Dall wrote:
> > We have to register the ITS iodevice before running the VM, because in
> > migration scenarios, we may be restoring a live device that wishes to
> > inject MSIs before we get a chance to run the VM.
> > 
> > All we need to register the ITS io device is the base address of the
> > ITS, so we can simply register that when the base address of the ITS is
> > set.
> > 
> > Signed-off-by: Christoffer Dall <cdall@linaro.org>
> > ---
> >  virt/kvm/arm/vgic/vgic-its.c | 29 +----------------------------
> >  virt/kvm/arm/vgic/vgic-v3.c  |  8 --------
> >  virt/kvm/arm/vgic/vgic.h     |  1 -
> >  3 files changed, 1 insertion(+), 37 deletions(-)
> > 
> > diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
> > index 9f7105c..375c503 100644
> > --- a/virt/kvm/arm/vgic/vgic-its.c
> > +++ b/virt/kvm/arm/vgic/vgic-its.c
> > @@ -2390,7 +2390,7 @@ static int vgic_its_set_attr(struct kvm_device *dev,
> >  
> >  		its->vgic_its_base = addr;
> >  
> > -		return 0;
> > +		return vgic_register_its_iodev(dev->kvm, its);
> >  	}
> >  	case KVM_DEV_ARM_VGIC_GRP_CTRL: {
> >  		const struct vgic_its_abi *abi = vgic_its_get_abi(its);
> > @@ -2467,30 +2467,3 @@ int kvm_vgic_register_its_device(void)
> >  	return kvm_register_device_ops(&kvm_arm_vgic_its_ops,
> >  				       KVM_DEV_TYPE_ARM_VGIC_ITS);
> >  }
> 
> This patch has the unfortunate side effect of breaking kvmtool 
> (although the ITS support patches are not merged yet). The code 
> sequence now requires that KVM_DEV_ARM_VGIC_CTRL_INIT has been issued 
> on the ITS *before* we can set the ITS base address.
> 
> I find it a bit odd (I see KVM_DEV_ARM_VGIC_CTRL_INIT as a way to say 
> "I'm done, do what you must and make it work"), but that's obviously 
> what QEMU must be doing (the save/restore sequence hints at that, but I 
> only just realized the issue). Of course, kvmtool does the opposite.
> 
> But now that we've coupled setting the address and mapping the iodev, 
> there is not much that's left for KVM_DEV_ARM_VGIC_CTRL_INIT, and I 
> wonder why we're keeping it (other than for backward compatibility)?
> 
> We're now unable to set the address more than once (fair enough). What 
> is also interesting is that this makes it plain obvious that we have a 
> race between setting the address and registering the device (no lock is 
> taken here, and two threads could try and play a dirty game on us).
> 
> I've come up with the two following patches, that seem to make it work.

Both patches look good, thanks.

-Christoffer

  reply	other threads:[~2017-05-08 19:21 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-08 11:54 [PATCH 0/8] Fixes to v7 of the vITS save/restore series Christoffer Dall
2017-05-08 11:54 ` Christoffer Dall
2017-05-08 11:54 ` [PATCH 1/8] KVM: arm/arm64: Clarification and relaxation to ITS save/restore ABI Christoffer Dall
2017-05-08 11:54   ` Christoffer Dall
2017-05-08 16:03   ` Auger Eric
2017-05-08 16:03     ` Auger Eric
2017-05-08 11:54 ` [PATCH 2/8] KVM: arm/arm64: vgic: Rename kvm_vgic_vcpu_init to kvm_vgic_vcpu_enable Christoffer Dall
2017-05-08 11:54   ` Christoffer Dall
2017-05-08 16:03   ` Auger Eric
2017-05-08 16:03     ` Auger Eric
2017-05-08 11:54 ` [PATCH 3/8] KVM: arm/arm64: Refactor vgic_register_redist_iodevs Christoffer Dall
2017-05-08 11:54   ` Christoffer Dall
2017-05-08 16:03   ` Auger Eric
2017-05-08 16:03     ` Auger Eric
2017-05-08 18:38     ` Christoffer Dall
2017-05-08 18:38       ` Christoffer Dall
2017-05-08 11:54 ` [PATCH 4/8] KVM: arm/arm64: Make vgic_v3_check_base more broadly usable Christoffer Dall
2017-05-08 11:54   ` Christoffer Dall
2017-05-08 16:13   ` Auger Eric
2017-05-08 16:13     ` Auger Eric
2017-05-08 17:18     ` Christoffer Dall
2017-05-08 17:18       ` Christoffer Dall
2017-05-08 17:39       ` Auger Eric
2017-05-08 17:39         ` Auger Eric
2017-05-08 19:10         ` Christoffer Dall
2017-05-08 19:10           ` Christoffer Dall
2017-05-08 11:54 ` [PATCH 5/8] KVM: arm/arm64: Slightly rework kvm_vgic_addr Christoffer Dall
2017-05-08 11:54   ` Christoffer Dall
2017-05-08 16:19   ` Auger Eric
2017-05-08 16:19     ` Auger Eric
2017-05-08 11:54 ` [PATCH 6/8] KVM: arm/arm64: Register iodevs when setting redist base and creating VCPUs Christoffer Dall
2017-05-08 11:54   ` Christoffer Dall
2017-05-08 17:09   ` Auger Eric
2017-05-08 17:09     ` Auger Eric
2017-05-08 17:20     ` Christoffer Dall
2017-05-08 17:20       ` Christoffer Dall
2017-05-08 11:54 ` [PATCH 7/8] KVM: arm/arm64: Register ITS iodev when setting base address Christoffer Dall
2017-05-08 11:54   ` Christoffer Dall
2017-05-08 17:12   ` Auger Eric
2017-05-08 17:12     ` Auger Eric
2017-05-08 17:41   ` Marc Zyngier
2017-05-08 17:41     ` Marc Zyngier
2017-05-08 19:21     ` Christoffer Dall [this message]
2017-05-08 19:21       ` Christoffer Dall
2017-05-08 11:54 ` [PATCH 8/8] KVM: arm/arm64: vgic-its: Cleanup after failed ITT restore Christoffer Dall
2017-05-08 11:54   ` Christoffer Dall
2017-05-08 17:20   ` Auger Eric
2017-05-08 17:20     ` Auger Eric
2017-05-08 12:49 ` [PATCH 9/8] KVM: arm/arm64: Don't call map_resources when restoring ITS tables Christoffer Dall
2017-05-08 12:49   ` Christoffer Dall
2017-05-08 17:22   ` Auger Eric
2017-05-08 17:22     ` Auger Eric

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=20170508192153.GM28342@cbox \
    --to=cdall@linaro.org \
    --cc=eric.auger@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=marc.zyngier@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.