All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoffer Dall <cdall@kernel.org>
To: Andre Przywara <andre.przywara@arm.com>
Cc: Christoffer Dall <christoffer.dall@linaro.org>,
	kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org,
	Marc Zyngier <marc.zyngier@arm.com>,
	Eric Auger <eric.auger@redhat.com>
Subject: Re: [PATCH v5 2/8] KVM: arm/arm64: Factor out functionality to get vgic mmio requester_vcpu
Date: Mon, 4 Dec 2017 20:21:01 +0100	[thread overview]
Message-ID: <20171204192101.GF32397@cbox> (raw)
In-Reply-To: <aab23eee-aa3b-9349-6e78-473beeb46969@arm.com>

On Fri, Dec 01, 2017 at 06:04:32PM +0000, Andre Przywara wrote:
> Hi,
> 
> On 20/11/17 19:16, Christoffer Dall wrote:
> > We are about to distinguish between userspace accesses and mmio traps
> > for a number of the mmio handlers.  When the requester vcpu is NULL, it
> > mens we are handling a userspace acccess.
> > 
> > Factor out the functionality to get the request vcpu into its own
> > function, mostly so we have a common place to document the semantics of
> > the return value.
> > 
> > Also take the chance to move the functionality outside of holding a
> > spinlock and instead explicitly disable and enable preemption.  This
> > supports PREEMPT_RT kernels as well.
> > 
> > Acked-by: Marc Zyngier <marc.zyngier@arm.com>
> > Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
> > ---
> >  virt/kvm/arm/vgic/vgic-mmio.c | 43 +++++++++++++++++++++++++++----------------
> >  1 file changed, 27 insertions(+), 16 deletions(-)
> > 
> > diff --git a/virt/kvm/arm/vgic/vgic-mmio.c b/virt/kvm/arm/vgic/vgic-mmio.c
> > index deb51ee16a3d..6113cf850f47 100644
> > --- a/virt/kvm/arm/vgic/vgic-mmio.c
> > +++ b/virt/kvm/arm/vgic/vgic-mmio.c
> > @@ -122,6 +122,26 @@ unsigned long vgic_mmio_read_pending(struct kvm_vcpu *vcpu,
> >  	return value;
> >  }
> >  
> > +/*
> > + * This function will return the VCPU that performed the MMIO access and
> > + * trapped from twithin the VM, and will return NULL if this is a userspace
> > + * access.
> > + *
> > + * We can disable preemption locally around accessing the per-CPU variable
> > + * because even if the current thread is migrated to another CPU, reading the
> > + * per-CPU value later will give us the same value as we update the per-CPU
> > + * variable in the preempt notifier handlers.
> 
> This comment left me scratching my head a bit. Maybe you could change it
> to point out that ... it's safe to *enable* preemption after the call
> again, because of said reasons? Because disabling preemption before
> accessing a per-CPU variable is not really an issue.

I'll try to clarify.

> 
> Apart from that it's fine.
> 
> Reviewed-by: Andre Przywara <andre.przywara@arm.com>
> 
Thanks,
-Christoffer

WARNING: multiple messages have this Message-ID (diff)
From: cdall@kernel.org (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 2/8] KVM: arm/arm64: Factor out functionality to get vgic mmio requester_vcpu
Date: Mon, 4 Dec 2017 20:21:01 +0100	[thread overview]
Message-ID: <20171204192101.GF32397@cbox> (raw)
In-Reply-To: <aab23eee-aa3b-9349-6e78-473beeb46969@arm.com>

On Fri, Dec 01, 2017 at 06:04:32PM +0000, Andre Przywara wrote:
> Hi,
> 
> On 20/11/17 19:16, Christoffer Dall wrote:
> > We are about to distinguish between userspace accesses and mmio traps
> > for a number of the mmio handlers.  When the requester vcpu is NULL, it
> > mens we are handling a userspace acccess.
> > 
> > Factor out the functionality to get the request vcpu into its own
> > function, mostly so we have a common place to document the semantics of
> > the return value.
> > 
> > Also take the chance to move the functionality outside of holding a
> > spinlock and instead explicitly disable and enable preemption.  This
> > supports PREEMPT_RT kernels as well.
> > 
> > Acked-by: Marc Zyngier <marc.zyngier@arm.com>
> > Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
> > ---
> >  virt/kvm/arm/vgic/vgic-mmio.c | 43 +++++++++++++++++++++++++++----------------
> >  1 file changed, 27 insertions(+), 16 deletions(-)
> > 
> > diff --git a/virt/kvm/arm/vgic/vgic-mmio.c b/virt/kvm/arm/vgic/vgic-mmio.c
> > index deb51ee16a3d..6113cf850f47 100644
> > --- a/virt/kvm/arm/vgic/vgic-mmio.c
> > +++ b/virt/kvm/arm/vgic/vgic-mmio.c
> > @@ -122,6 +122,26 @@ unsigned long vgic_mmio_read_pending(struct kvm_vcpu *vcpu,
> >  	return value;
> >  }
> >  
> > +/*
> > + * This function will return the VCPU that performed the MMIO access and
> > + * trapped from twithin the VM, and will return NULL if this is a userspace
> > + * access.
> > + *
> > + * We can disable preemption locally around accessing the per-CPU variable
> > + * because even if the current thread is migrated to another CPU, reading the
> > + * per-CPU value later will give us the same value as we update the per-CPU
> > + * variable in the preempt notifier handlers.
> 
> This comment left me scratching my head a bit. Maybe you could change it
> to point out that ... it's safe to *enable* preemption after the call
> again, because of said reasons? Because disabling preemption before
> accessing a per-CPU variable is not really an issue.

I'll try to clarify.

> 
> Apart from that it's fine.
> 
> Reviewed-by: Andre Przywara <andre.przywara@arm.com>
> 
Thanks,
-Christoffer

  reply	other threads:[~2017-12-04 19:21 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-20 19:16 [PATCH v5 0/8] Handle forwarded level-triggered interrupts Christoffer Dall
2017-11-20 19:16 ` Christoffer Dall
2017-11-20 19:16 ` [PATCH v5 1/8] KVM: arm/arm64: Remove redundant preemptible checks Christoffer Dall
2017-11-20 19:16   ` Christoffer Dall
2017-12-01 18:04   ` Andre Przywara
2017-12-01 18:04     ` Andre Przywara
2017-11-20 19:16 ` [PATCH v5 2/8] KVM: arm/arm64: Factor out functionality to get vgic mmio requester_vcpu Christoffer Dall
2017-11-20 19:16   ` Christoffer Dall
2017-12-01 18:04   ` Andre Przywara
2017-12-01 18:04     ` Andre Przywara
2017-12-04 19:21     ` Christoffer Dall [this message]
2017-12-04 19:21       ` Christoffer Dall
2017-11-20 19:16 ` [PATCH v5 3/8] KVM: arm/arm64: Don't cache the timer IRQ level Christoffer Dall
2017-11-20 19:16   ` Christoffer Dall
2017-12-01 18:04   ` Andre Przywara
2017-12-01 18:04     ` Andre Przywara
2017-11-20 19:16 ` [PATCH v5 4/8] KVM: arm/arm64: vgic: Support level-triggered mapped interrupts Christoffer Dall
2017-11-20 19:16   ` Christoffer Dall
2017-11-20 19:16 ` [PATCH v5 5/8] KVM: arm/arm64: Support a vgic interrupt line level sample function Christoffer Dall
2017-11-20 19:16   ` Christoffer Dall
2017-11-20 19:16 ` [PATCH v5 6/8] KVM: arm/arm64: Support VGIC dist pend/active changes for mapped IRQs Christoffer Dall
2017-11-20 19:16   ` Christoffer Dall
2017-11-29 15:13   ` Andrew Jones
2017-11-29 15:13     ` Andrew Jones
2017-12-04 19:31     ` Christoffer Dall
2017-12-04 19:31       ` Christoffer Dall
2017-11-20 19:16 ` [PATCH v5 7/8] KVM: arm/arm64: Provide a get_input_level for the arch timer Christoffer Dall
2017-11-20 19:16   ` Christoffer Dall
2017-11-29 15:13   ` Andrew Jones
2017-11-29 15:13     ` Andrew Jones
2017-11-20 19:16 ` [PATCH v5 8/8] KVM: arm/arm64: Avoid work when userspace iqchips are not used Christoffer Dall
2017-11-20 19:16   ` Christoffer Dall

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=20171204192101.GF32397@cbox \
    --to=cdall@kernel.org \
    --cc=andre.przywara@arm.com \
    --cc=christoffer.dall@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.